I am trying to validate that a user input valid information at the prompt but I keep getting errors please help!
Here is my code:
private double computeAverageSales() { WebHost webHost; double average = 0; double total = 0; int counter = 0; for (int i = 0; i <= 0; i++) { while (true) { do { System.out.print("Please enter the price of the new package: $"); while (!scanner.hasNextDouble()) { System.out.println("Please enter a postive number!"); scanner.next(); } double webHostPrice = scanner.nextDouble(); total = webHostPrice + total; counter++; while (webHostPrice <= 0) { break; } } do { System.out.print("What will be the product ID: "); while (!scanner.hasNextInt()) { System.out.print("Please enter a valid product ID!"); scanner.next(); int webHostId = scanner.nextInt(); scanner.nextLine(); } } do { System.out.print("What is the product name: "); while (!scanner.hasNext("")) { System.out.print("Please enter the product name!"); scanner.next(); String webHostName = scanner.nextLine(); do { System.out.print("Please enter the required Bandwidth needed for your site? "); while (!scanner.hasNextDouble()) { System.out.print("Please enter a positive number!"); scanner.next(); double webHostBandwidth = scanner.nextDouble(); } do { System.out.print("How many FTP accounts do you need? "); while (!scanner.hasNextInt()) { System.out.print("Please enter a valid number!"); scanner.next(); int webHostFtp = scanner.nextInt(); scanner.nextLine(); do { System.out.print("How many email accounts do you need? "); while (!scanner.hasNextInt()) { System.out.print("Please enter a valid number"); scanner.next(); do { System.out.print("What is your domain name? "); while (!scanner.hasNext("")) { System.out.print("Please enter a valid domain name"); scanner.next(); int webHostMail = scanner.nextInt(); scanner.nextLine(); String webHostDomain = scanner.nextLine(); webHost = new WebHost(webHostBandwidth, webHostPrice, webHostFtp, webHostMail, webHostId, webHostDomain, webHostName); } average = total / (counter - 1); return average; } } }
I know it is messy but that is me messing with it for three days please help.