Respuesta :
Answer:
The program to this question can be defined as follows:
Program:
import java.util.*; //import package
public class Main //defining class
{
public static void main(String[] as) //defining main method
{
Scanner ax= new Scanner(System.in);//create Scanner class object for user-input
String val; //defining String variable
int x;//defining an integer variable
System.out.print("Enter string value first then numeric, and for exit 'quit & 0': \n");
val = ax.next(); //input value
x = ax.nextInt();//input value
while(!(val.equals("quit") && x==0)) //Check value
{
System.out.println("Eating "+x+" "+val+" a day keeps the doctor away."); //print value
val = ax.next(); //input value
x= ax.nextInt(); //input value
}
}
}
Output:
Enter string value first then numeric, and for exit 'quit & 0':
apple 5
Eating 5 apple a day keeps the doctor away.
shoes 2
Eating 2 shoes a day keeps the doctor away.
quit 0
Explanation:
In the above program, two variable "val" and "x" is declared, in which "val" is string variable and "x" is integer variable, in the next line, a while loop is declared, which can be described as follows:
In the loop, a condition is checked, that "val" is equal to "quit" and x is equal to "0", inside the loop, it will input value from the user-end.
Answer:
in python:
while True:
inter,string= input().split() #use split to write input in the same line
if(inter=="quit"):
break
else:
print("Eating {} {} a day keeps the doctor away.".format(string,inter))
Explanation: