can i ask whats the problem in my code? its done but the part of the yes or no which is this System.out.println("A refrigerator costs $2.50 extra each day would you like that? (Y/N)");
will be skipped and insted the System.out.println("Number of Days Staying :" + dys);
will be printed.
import java.util.Scanner;
public class Test
{
public static void main (String[] args)
{
Scanner scan = new Scanner(System.in);
String rt;
String a = new String ("G");
String b = new String ("P");
String c = new String ("L");
System.out.println(" Welcome to Easy Living Resort Hotel");
System.out.println("------------------------------------------");
System.out.println(" Room Type Daily Rate ");
System.out.println(" ~~~~~~~~~ ~~~~~~~~~~ ");
System.out.println(" G- Garden Pool View $125.00 ");
System.out.println(" P- Pool View $145.00 ");
System.out.println(" L- Lake View $180.00 ");
System.out.println("Please select your room type");
rt = scan.nextLine();
if(rt.equalsIgnoreCase("G")) {
System.out.println("Garden Pool View");
} else if(rt.equalsIgnoreCase("P")) {
System.out.println("Pool View");
} else {
System.out.println("Lake view");
}
int dys;
System.out.println("------------------------------------------");
System.out.println("Number of Days you are staying in: ");
dys = scan.nextInt();
String r;
String d = new String ("Y");
String e = new String ("N");
System.out.println("A refrigerator costs $2.50 extra each day would you like that? (Y/N)");
r = scan.nextLine();
if(r.equalsIgnoreCase("Y")) {
System.out.println("Y");
}else if (r.equals("N")) {
System.out.println("N");
}
System.out.println("Number of Days Staying :" + dys);
//System.out.println("
}
}
Aucun commentaire:
Enregistrer un commentaire