Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileNotFoundException;
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6. private static Scanner scannerfile;
  7. private static Scanner scanner;
  8. static String userInput; //A variable to store the user input
  9. static double taxRate = 0; //A double to store the custom tax rate because tax rate will be a real number
  10. public static void main(String[] args) throws FileNotFoundException {
  11. File file=new
  12. File("C:\\Users\\Me\\Documents\\Coursework\\rooms.txt");
  13. }
  14.  
  15. {
  16. scannerfile = new Scanner(file);
  17. scanner = new Scanner(System.in);
  18.  
  19. System.out.println("--Welcome to the room tax system"
  20. +"Specify Custom Tax Rate[Y/N]:");
  21. userInput=scanner.nextLine();
  22.  
  23. while (true) { //An infinite loop until the code path reaches the break statement
  24. System.out.println("--Welcome to the room tax system"
  25. +"Specifiy Custom Tax Rate[Y/N]:");
  26. userInput=scanner.nextLine();
  27. }
  28.  
  29. if (userInput.equals("Y") || userInput.equals("N")) {
  30. System.out.println("Registered");
  31. break;
  32. } else {
  33. System.out.println("Please try again");
  34.  
  35.  
  36.  
  37. if (userInput.startsWith("Y"));
  38. System.out.print("Specify Custom Tax Rate (%);");
  39. taxRate=scanner.nextDouble();
  40.  
  41. if (userInput.startsWith("N"));
  42. System.out.print("Specify Custom Tax Rate (%);");
  43. taxRate=scanner.nextDouble();
  44.  
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement