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
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc00246d7-210d-47f4-964d-360b3bcbb90b%2F4ed88f18-14c4-479a-be06-cb89d2c65986%2Fp5wvzw_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)