int store1, store2, store3, store4, store5;
char ans = 'e';
String gen;
Scanner scan = new Scanner(System.in);
Random randNum = new Random();
System.out.println("Do you want to enter the sales figure (e) or do you want it randomly generated (r)? ");
gen=scan.nextLine();
if (ans == 'e' || ans == 'E')
{
System.out.println("Enter todays sales for: ");
System.out.println("Store 1: ");
store1=scan.nextInt();
System.out.println("Store 2: ");
store2=scan.nextInt();
System.out.println("Store 3: ");
store3=scan.nextInt();
System.out.println("Store 4: ");
store4=scan.nextInt();
System.out.println("Store 5: ");
store5=scan.nextInt();
scan.close();
}
else
{
System.out.println("Store 1: ");
store1=randNum.nextInt(10);
System.out.println("Store 2: ");
store2=randNum.nextInt(10);
System.out.println("Store 3: ");
store3=randNum.nextInt(10);
System.out.println("Store 4: ");
store4=randNum.nextInt(10);
System.out.println("Store 5: ");
store5=randNum.nextInt(10);
}
}
}
Need to figure out how to get this code working properly. Right now it only recognizes the 'e' and 'E' enter but not if i enter anything else. When it does do the else the random number gen won't work.