Initiate Mage
- Joined
- Aug 22, 2013
- Messages
- 1
- Reaction score
- 0
hi,
i started college a few weeks ago, and it includes java, and i've got a question, i hope someone is able to help me.
my question is something with the brackets, if the code = A it will run the whole progam? i mean with that will the program check if the code = O and so on? my teacher asked if the code equals to A it doesn't have to run the rest of the program because the price is already known,
so that's the question ; are the brackets placed correctly so it will run only the red marked code if code = A
i hope someone is able to help me, thanks in advance.
i started college a few weeks ago, and it includes java, and i've got a question, i hope someone is able to help me.
Code:
public class oef8 {
public static void main(String[] args) {
String seizoen, code;
int aantalN,ster;
double prijs;
ster = Invoer.leesInt("give the amount of stars");
seizoen = Invoer.leesString("give in the season");
code = Invoer.leesString("give the code");
aantalN = Invoer.leesInt("amount of nights");
[B][COLOR=#ff0000]if[/COLOR][COLOR=#ff0000](code.equals("A")){
prijs = aantalN * 80;
}
else if(ster == 1){
prijs = 30;
}
else if(ster <= 3){
prijs = 40;
}
else prijs = 55;[/COLOR][/B][COLOR=#ff0000]
[/COLOR]
if(code.equals("O")){
prijs = prijs *1.2;
}
else if(code.equalsIgnoreCase("H")){
prijs = prijs * 1.5;
}
else prijs = prijs * 1.6;
if(seizoen.equals("L") && (code.equals("O") || code.equals("H"))){
prijs = prijs * 0.9;
}
prijs = prijs * aantalN;
System.out.println("de prijs is" + prijs);
}
}
my question is something with the brackets, if the code = A it will run the whole progam? i mean with that will the program check if the code = O and so on? my teacher asked if the code equals to A it doesn't have to run the rest of the program because the price is already known,
so that's the question ; are the brackets placed correctly so it will run only the red marked code if code = A
i hope someone is able to help me, thanks in advance.