Jesper de Jong wrote:Welcome to the Ranch.
At first sight, it looks like the logic of the program is OK.
However, I see some things that are not valid Java code. For example, lines 41 and 42:
Did you try to compile your source code? You would have gotten errors.
When you write a program, don't write a whole bunch of code at once. Write a few lines, try to compile it, and see if the compiler reports any errors. If there are errors, fix them first. If you write a long and complicated program and you try compiling it afterwards, and you have errors, it will be much harder to understand what causes the compile errors.
I ran it up to the strings and all of that is fine. I understand the logic. What I need help with is how to actually say what I'm trying to say in java code. My first question is how do you define two words (strings, I'm assuming) that will be input from the user. And if the user does not enter either one (has to be both), output will say enter the right
word. When they do enter the right word, I want the calculation that I have defined for that word to print out along with "your answer is...".
Errors that show up:
C:\Users\Charley\Documents\CSC 110\Programs\Un.java:57: error: '(' expected
if else (input.equals("person")){
^
C:\Users\Charley\Documents\CSC 110\Programs\Un.java:57: error: illegal start of expression
if else (input.equals("person")){
^
C:\Users\Charley\Documents\CSC 110\Programs\Un.java:57: error: ')' expected
if else (input.equals("person")){
^
C:\Users\Charley\Documents\CSC 110\Programs\Un.java:57: error: ';' expected
if else (input.equals("person")){
^
C:\Users\Charley\Documents\CSC 110\Programs\Un.java:66: error: reached end of file while parsing
}
^
5 errors
Tool completed with exit code 1
So if I go thru it step by step, the first, most important question is how I define those two words so they are linked to these formulas (total = band + totalplate + totalrent and person= total/person) and when they are entered they are calculated and output the answer.