Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input string is quit 0. Ex: If the input is: apples 5 shoes 2 quit 0 the output is: Eating 5 apples a day keeps

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter2: Problem Solving Using C++using
Section: Chapter Questions
Problem 8PP: (Modify) a. Modify the program you wrote for Exercise 7 to provide the mass of a person as an...
icon
Related questions
Question

Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input string is quit 0.

Ex: If the input is:

apples 5 shoes 2 quit 0

the output is:

Eating 5 apples a day keeps the doctor away. Eating 2 shoes a day keeps the doctor away.

 

import java.util.Scanner;

public class LabProgram {
public static void main(String[] args) {

Scanner scnr = new Scanner(System.in);

String some_string;
int some_int;

some_string = scnr.next();
some_int = scnr.nextInt();

if (some_int != 0){
System.out.println("Eating " + some_int + " " + some_string + " a day keeps the doctor away.");
}
}
}

My program wil online output the first input but not the next. What am I missing???

Enter program input (optional)
apples 5
shoes 2
Input (from above)
LabProgram.java
(Your program)
Run program
Output (shown below)
Program output displayed here
Eating 5 apples a day keeps the doctor away.
Transcribed Image Text:Enter program input (optional) apples 5 shoes 2 Input (from above) LabProgram.java (Your program) Run program Output (shown below) Program output displayed here Eating 5 apples a day keeps the doctor away.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr