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
Python programming exercise 3.3 (guess.py) Modify the guessing-game program so that the user thinks of a...
Python programming exercise 3.3 (guess.py) Modify the guessing-game program so that the user thinks of a number that the computer must guess.
user will input a set of integers until 0 is input. When each number is input,...
user will input a set of integers until 0 is input. When each number is input, output whether the number input is it even or odd. Additionally, count the even numbers input. When 0 is input, output the count of the even numbers. Write the code here including the class definition and main function:
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...
Binary Search Tree Code in Java Write a program that prompts user to enter however many...
Binary Search Tree Code in Java Write a program that prompts user to enter however many numbers they want to add to the binary search tree. Then have the user input numbers until the tree contains that many elements. If the user enters a number that already exists in the tree, then a message should be displayed "Number is already in the tree". Once all elements are added to the tree print its contents in sorted order. Assume all user...
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...
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.
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.