0
How to make a java code that will ask user the number of times that user wants to print word "eggs"and then ask to do it again
How to make a java code that will ask user the number of times that user wants to print word "eggs"and then print the word "eggs" as much times as the number inserted and then ask the user if he wants to start again.
3 odpowiedzi
+ 2
//you must first create a scanner to get the user's input
Scanner sc=new Scanner(System.in);
//then ask for the eggs
System.out.println("ask for eggs");
int Noeggs=sc.nextInt(); //number of eggs
for(int i=0;i<Noeggs; i++){
// create a loop to print eggs as many times as the user asks
System. out. println("eggs");
}
System. out. println("type 1 if you want to repeat or 2 if you don't");
int t=sc.nextInt;
it should look something like that. If you want the program to rerun automatically then put it into a loop and run while(t==1)
0
Begin by printing eggs once
Then use a loop to print lets say 10 times
Tell me after you have done this we continue
0