Im currently in a JAVA class in college and we had to build a program that calculated commission. i think im in the ball park here with my code but when i run it i cant get past the second question. Im running it on netbeans can anyone see what i did wrong here? It has to be near the error message because i cant get past that point on the code. Now i do have a string that does not allow letters to be input into the second question im not sure if that is the problem or not either.
package salesperson; import java.util.Scanner; public class Salesperson { public static void main(String[] args) { final double salary = 40000.00; final double commissionRate = 0.05; final double pricePerSale = 250.00; boolean addperson = true; Scanner sc = new Scanner(System.in); System.out.println ("Calculate your commission and total pay"); System.out.println(" "); while (addperson == true){ double total = 0; int currentNumber; String currentString; String name; String yesNo; boolean exit; boolean isNumber; System.out.println ("Enter name: "); name = sc.next(); System.out.println(" "); do { System.out.print ("Enter amount of sales: "); currentString = sc.next(); isNumber = isANumber(currentString); if (isNumber == true) { currentNumber = Integer.parseInt(currentString); if (currentNumber > 0) { total += currentNumber * pricePerSale; } } { System.out.println("ERROR: only enter whole numbers"); } } while (isNumber == false); System.out.println(""); total = total * commissionRate; System.out.print (name + "Earned"); System.out.printf("$%2.2f",total); System.out.println(" in commissions and Earned "); total += salary; System.out.printf("$%2.2f",total); System.out.println(" this year"); System.out.println(""); do { System.out.println("Do you want to check another name y/n : "); yesNo = sc.next(); System.out.println(""); switch (yesNo) { case "n": case "N": addperson = false; exit = true; break; case "y": case "Y": exit = true; break; default: System.out.println ("Enter y or n only"); exit = false; } }while (exit == false); } } public static boolean isANumber (String s){ int i =0; boolean valid = true; if (s.length()==0); valid = false; while (i < s.length()){ if (!Character.isDigit(s.charAt(i))){ valid =false; break; } i++; } return valid; } }