Answer:
I am writing a C++ and JAVA program.
import java.util.Scanner; //for using input output functions
public class LabProgram { // class name
public static void main(String[] args) {//start of main function body
Scanner input = new Scanner(System.in);
// creates input instance of Scanner type
String str; // declares String type variable str for a string value
int num; // declares integer type variable num to hold an integer value
str = input.next();
//scans and reads input string from user
num = input.nextInt(); //scans and reads input integer from user
//while loop continues to execute until user enters quit 0
while(str!="quit" && num!=0) {
/* prints the following message, for example if value of num = 2 and value of str = apples then the following print statement prints Eating 2 apples a day keeps the doctor away. */
System.out.println("\nEating " + num +" " + str + " a day keeps the doctor away.");
//takes string and integer as input again and keep taking input until user //enters quit 0
str = input.next();
num = input.nextInt(); } } }
Explanation:
The program is well explained in the comments mentioned with each statement of the program. The program simply prompts user to enter a string and an integer. The while loop keeps executing until user enters quit 0. The program keeps taking input string and integer from user and prints the message System.out.println("\nEating " + num +" " + str + " a day keeps the doctor away."); The loop breaks when the use enters quit 0. The screenshot of the program along with its output is attached.