Hi,
I have a program that loops ten times and asks a question each time with an appropriate response for the user's input. My problem is i'm trying to get the program to ask at the end, "Do you want to go again? Type "Yes" or "No"."
Below isn't my actual program, I made a mock up because the actual one is for college and I don't want to get into trouble.
class Mock { public static void main(String[] args) { int ans= 0; int loop =0; int i=1; int end= 0; do { System.out.println("Do u like number "+i) ;i++; ans = EasyIn.getInt(); if (ans == 1) { System.out.println("Good"); } else if (ans == 2) { System.out.println("Thats OK!"); } else { --i; --loop; System.out.println("1 or 2 only!!"); System.out.println(); } { loop++; } } while (loop <10); } }
I added this to the end but i'm sure that its completely wrong and its missing stuff also.
System.out.println("Would you like to continue? '1 = yes' '2 = no'") end = EasyIn.getInt if { (end == 1) //Need to go back to the start of the loop. } else { System.out.println("Bye") } while (loop <10); }
PS: I was using int's just to make the example easier.
Thanks you for any help.