Home > Back-end >  Java topic is really don't understand, please
Java topic is really don't understand, please

Time:12-26

Trouble you help me have a look at that place was wrong that if, else if I get dizzy

Thank you for the






System. The out. Print (" please enter your travel in: 1 ~ 12 ");
Scanner input=new Scanner (System. In);
Int time=input. NextInt ();
System. Out.println (" would you choose first class or economy class?" );
System. The out. Println (" first class type 1, type 2 economy class ");
String a=input. Next ();
Double money=5000;

If (a.e quals (" 2 ")) {
System. The out. Print (" ");
} the if (time<=10 & amp; & Time> {
=4)System. The out. Print (" your ticket price is: "+ money * 0.8);
} else if (time>=10 & amp; & Time<{
=4)System. The out. Print (" your ticket price is: "+ money * 0.4);
} else if (a.e quals (" 1 ")) {
System. The out. Print (" ");
} the if (time<=10 & amp; & Time> {
=4)System. The out. Print (" your ticket price is: "+ money * 0.9);
} else if (time>=10 & amp; & Time<{
=4)System. The out. Print (" your ticket price is: "+ money * 0.5);
}
}


Results there are two, not understand

Please enter your travel in: 1 ~ 12
5
Would you choose first class or economy class?
First-class input 1, economy enter 2
2
Your ticket prices for: your ticket price is 4000.0:4500.0

CodePudding user response:

 
System. The out. Print (" please enter your travel in: 1 ~ 12 ");
Scanner input=new Scanner (System. In);
Int time=input. NextInt ();
System. Out.println (" would you choose first class or economy class?" );
System. The out. Println (" first class type 1, type 2 economy class ");
Int a=input. NextInt ();
Double money=5000;
Double real=0;


Boolean busy=time & lt;=10 & amp; & Time & gt;=4;

If (busy) {

If (a==1) {
Real=money * 0.9;
} else {
Real=money * 0.8;
}
} else {
If (a==1) {
Real=money * 0.5;
} else {
Real=money * 0.4;
}
}


System. The out. Print (" your ticket price is: "+ real);
  • Related