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???
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images