Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- public class Main {
- private static Scanner scannerfile;
- private static Scanner scanner;
- static String userInput; //A variable to store the user input
- static double taxRate = 0; //A double to store the custom tax rate because tax rate will be a real number
- public static void main(String[] args) throws FileNotFoundException {
- File file=new
- File("C:\\Users\\Me\\Documents\\Coursework\\rooms.txt");
- }
- {
- scannerfile = new Scanner(file);
- scanner = new Scanner(System.in);
- System.out.println("--Welcome to the room tax system"
- +"Specify Custom Tax Rate[Y/N]:");
- userInput=scanner.nextLine();
- while (true) { //An infinite loop until the code path reaches the break statement
- System.out.println("--Welcome to the room tax system"
- +"Specifiy Custom Tax Rate[Y/N]:");
- userInput=scanner.nextLine();
- }
- if (userInput.equals("Y") || userInput.equals("N")) {
- System.out.println("Registered");
- break;
- } else {
- System.out.println("Please try again");
- if (userInput.startsWith("Y"));
- System.out.print("Specify Custom Tax Rate (%);");
- taxRate=scanner.nextDouble();
- if (userInput.startsWith("N"));
- System.out.print("Specify Custom Tax Rate (%);");
- taxRate=scanner.nextDouble();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement