Respuesta :
Answer:
Following are the program in the Python Programming Language.
#set the infinite while loop
while(True):
#get string input from the user
name=input()
#get integer input from the user
num=int(input())
#set the if statement to break the loop
if(num==0):
break
#otherwise, print the following output
else:
print("Eating {} {} a day keeps the doctor away.".format(num, name))
Output:
oranges
5
Eating 5 oranges a day keeps the doctor away.
apple
0
Explanation:
Following are the description of the program:
- Set the loop that iterates at infinite times and inside the loop.
- Declare two variables which are 'name' that get string type input from the user and 'num' that get integer type input from the user.
- Set the if conditional statement for break the infinite while loop.
- Otherwise, it prints the following output.
The code below is in Java
It uses an indefinite while loop to get the inputs from the user and places the inputs correspondingly in the text. If the inputs are "quit" and 0, the program stops.
Comments are used to explain the each line.
The output can be seen in the attachment.
*Note that we use extra input.nextLine(); after getting the inputs, that is used to prevent the input miss match exception. We need to move cursor to the new line after using nextInt() if the next input statement uses nextLine().
//Main.java
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
//Scanner object to be able to get input from the user
Scanner input = new Scanner(System.in);
// Declaring the corresponding variables for string and integer
String s;
int x;
//Creating an indefinite while loop
while(true){
//Getting the string and integer inputs.
s = input.nextLine();
x = input.nextInt();
input.nextLine();
//Checking if the inputs are "quit" and 0. If that is the case, stop the loop using the break statement.
if(s.equals("quit") && x == 0)
break;
//Print the required statement by placing the string and integer you get from the user
System.out.println("Eating " + x + " " + s + " a day keeps the doctor away.");
}
}
}
You may read more about the loops in the following link:
https://brainly.com/question/14577420