Question

Modify the CarRecall for Exercise Set 3 to allow the user to input as many model...

Modify the CarRecall for Exercise Set 3 to allow the user to input as many model numbers as needed. Use 0 as a sentinel to end user input. ( Java programming )

Homework Answers

Answer #1

Here you go:

The program terminates when the user inputs 0.

import java.util.Scanner;

public class Main {

public static void main(String []args) {

int num;

Scanner sc = new Scanner(System.in);

System.out.println("enter number: ");

while((num = sc.nextInt()) > 0) {

System.out.println("Keep Going!");

}

{

System.out.println("entered 0.");

System.exit(1);

}

}

}

========================================================

A sign of thumbs up would be appreciated.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Develop a spreadsheet application that will allow a user to input the basic information for the...
Develop a spreadsheet application that will allow a user to input the basic information for the analysis of a rectangular reinforced concrete cross section and that will then calculate the practical moment strength øMn. Set up the spreadsheet to be “user friendly” and fully label the output.
Covert the following Java program to a Python program: import java.util.Scanner; /** * Displays the average...
Covert the following Java program to a Python program: import java.util.Scanner; /** * Displays the average of a set of numbers */ public class AverageValue { public static void main(String[] args) { final int SENTINEL = 0; int newValue; int numValues = 0;                         int sumOfValues = 0; double avg; Scanner input = new Scanner(System.in); /* Get a set of numbers from user */ System.out.println("Calculate Average Program"); System.out.print("Enter a value (" + SENTINEL + " to quit): "); newValue =...
Create .py code allowing use input float # until sentinel val of 0 is inputted. When...
Create .py code allowing use input float # until sentinel val of 0 is inputted. When zero is entered, the program with end. Should out put the following: Amount of number (#) user input, Sum of # imputted, Avg. of the numbers imputted, Lowest # entered, and Highest # entered. Python
Create a program that allows the user to input a list of first names into one...
Create a program that allows the user to input a list of first names into one array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. The output should be a list of emial addresses where the address is of the following form: [email protected] Declare FirstName[100] as String Declare LastName[100] as String Declare email as String Declare K as Integer Declare index as Integer Write "Enter first and last name." Write...
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while...
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1, then with user input of 0, -17, then with user input of 0 1 0 -1. See "How to Use zyBooks". Also note: If the submitted code has an...
Write a Python program to calculate the area of a circle. The user needs to input...
Write a Python program to calculate the area of a circle. The user needs to input the value of the radius of the circle. area = 3.14 x radius x radius You should use a function named circlearea to perform the calculation 3. Write a Python program to calculate the area of a square. The user needs to input the value of the length of the square. area = len*len You should use a function named squarearea to perform the...
On Python Ask the user to input a min and a max value for a range...
On Python Ask the user to input a min and a max value for a range of numbers. Then use range(min, max) to: a) Loop through the range specified by the user and find all the numbers that are divisible by 3 and print them. b) Loop through the range and find only the first multiple of 3 and print it.
Insert a spin button and scroll bar in the Outsourcing Decision model to allow the user...
Insert a spin button and scroll bar in the Outsourcing Decision model to allow the user to easily change the production volume in Cell B12 from 500 to 3000. Which one is easier to use? Discuss the Pros and cons of each.
Write a C program that prompts the user to input as many unsigned(n) as the user...
Write a C program that prompts the user to input as many unsigned(n) as the user wants to type, terminated by non negative number You may assume without checking that when the user is supposed to type an unsigned, he nevertypes a double You may assume without checking that when the user is supposed to type an unsigned, he nevertypes a negative number. For each number the user types, output whether that number is prime or not. You won't need...
Use C++ Write a program that first reads in how many whole numbers the user wants...
Use C++ Write a program that first reads in how many whole numbers the user wants to sum, then reads in that many whole numbers, and finally outputs the sum of all the numbers greater than zero, the sum of all the numbers less than zero (which will be a negative number or zero), and the sum of all the numbers, whether positive, negative, or zero. The user enters the numbers just once each and the user can enter them...