Write a java program where you will enter as many numbers as you want and, in the end, when you press zero it will display the largest number.
Steps:
1) Create scanner object
2) Declare variable number and max;
3) Enter the number with prompt system
4) Declare number and input statement
5) Declare max which is equal to number (in other word any number that you enter is equal to max)
6) Declare the while condition where number is not equal to zero
7) Inside of that while brace condition declares number and his input statement
8) After that create selection if statement where number is greater than max variable
9) Declare after that, that variable max is equal to variable number
10) In the end show in print the max number Note: basically, after you enter numbers of your choice when you enter zero it should give you the largest number.
//The below code follows the steps exactly. However, the given steps compare zero also with the max in the end. if //you dont want zero to be compared with max in the end follow the second program
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int number,max;
System.out.print("Enter number: ");
number=sc.nextInt();
max=number;
while(number!=0)
{
System.out.print("Enter number: ");
number=sc.nextInt();
if(number>max)
max=number;
}
System.out.println("Max number: "+max);
}
}
![Main.java import java.util.Scanner; 2 public class Main 3 - { 4 public static void main(String[] args) 5 { 6 Scanner sc = new](http://img.homeworklib.com/questions/eb695280-bf3b-11eb-b1dd-bd737499ecb5.png?x-oss-process=image/resize,w_560)
// proram that doesnt include zero
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int number,max;
System.out.print("Enter number: ");
number=sc.nextInt();
max=number;
while(number!=0)
{
if(number>max)
max=number;
System.out.print("Enter number: ");
number=sc.nextInt();
}
System.out.println("Max number: "+max);
}
}
Write a java program where you will enter as many numbers as you want and, in...
// Group Names: // Date: // Program Description: // Import required packages //--> // Declare class (SwitchDoLab) //--> { // Declare the main method //--> { // Declare Constant integers SUM = 1, FACTORIAL = 2, QUIT = 3. //--> //--> //--> // Create an integer variable named choice to store user's option. //--> // Create a Scanner object // Create...
MATLAB QUESTION
8) Create a program that first prompts the user to enter any two numbers. Then prompt the user again to input as many numbers as they choose. Stop the program by inputting-1. Then, display the largest number and second largest number in the command window once the user kills the program. The built-in max function cannot be used. The figure below is an example of what the command window should look like when the code is ran. First...
Write a Java program to prompt for inputting an integer N, then enter N integers (a loop is needed), print the numbers user entered, and the amount of even and odd numbers (zero is even number). (1) Prompt for the user to input an integer and output the integer. (1 pts) Enter an integer: You entered: 5 (2) Prompt for the user to input N integers, output the numbers entered and the amount of even and odd numbers (9 pts)...
Java code Guessing Game Refinement. (The user thinks of a
number and the program guesses it) Program should be able to guess
correctly in 7 tries or lower.
Initialize a variable that represents the lowest possible
number to 0 (what type should this be?)
Initialize a variable that represent the highest possible
number to 100 (what type should this be?)
Initialize a Boolean variable that represents if we’ve
achieved the correct guess to false
Initialize a variable in which to...
Write a Java program to meet the following requirements: 1. Prompt the user to enter three strings by using nextLine(). Space can be part of the string). ( Note: your program requires using loop: for-loop, while-loop or do-while-loop to get the input String ) 2. Write a method with an input variable (string type).The method should return the number of lowercase letters of the input variable. 3. Get the number of the lowercase letters for each user input string by...
Write a program that asks the user how many integers they would like to enter. You can assume they will enter an integer >= 1. The program will then prompt the user to enter that many integers. After all the numbers have been entered, the program should display the largest and smallest of those numbers (no, you cannot use lists, or any other material we haven't covered). When you run your program it should match the following format: How many...
1- Write a program to read 10 numbers and find the average of these numbers. Use a while loop to read these numbers and keep track of input numbers read. Terminate the while loop with a sentinel value. 2- Now modify the program to find the maximum of these numbers as well. The program should print the number of elements read as input and run until -1 is entered. (-1 is the sentinel that terminates the loop and the program)...
Write a Java program to convert octal (integer) numbers into their decimal number equivalents (exactly the opposite of what you have done in Assignment 4). Make sure that you create a new Project and Java class file for this assignment. Your file should be named “Main.java”. You can read about octal-to-decimal number conversions on wikepedia Assignment 4 is at the bottom Objective Your program should prompt the user to enter a number of no greater than 8 digits. If the...
WRITE THIS PROGRAM IN JAVA CODING ONLY ! Program 1: In Order Using an IF/ELSE IF/ELSE structure, write a program that will prompt the user for three numbers and displays them in ascending order. First, the program will prompt the user for each of the three numbers. Next, find the smallest value of the three. Then decide which of the other two is the next smallest. Then have the program display the three numbers in ascending order. Be sure to...
Create a java program which will prompt a user to input a product and its cost. Using a while loop that will run until the sentinel value of “stop” (any case) is entered, the program will look for items with a cost greater than or equal to $100.00. The program will find the average cost of those items. Note: immediately after your statement containing input.nextDouble() you will need to add the following input.nextLine() statement. This will cause the input scanner...