In this lab, a prewritten Java program that computes the largest and smallest of three integer values

In this lab, a prewritten Java program that computes the largest and smallest of three integer values.

Instructions

Two variables named largest and smallest are assigned . Use these variables to store the largest and smallest of the three integer values. decide what other variables you will need and initialize them if appropriate.
program should prompt the user to enter 3 integers.
Write the rest of the program using assignment statements, and if else statements as appropriate.
There are comments in the code that tell you where you should write your statements. The output statements are written for you.

Execute the program by clicking the Run button at the bottom of the screen.
Using the input of -50, 53, 78, your output should be:

The largest value is 78
The smallest value is -50

// LargeSmall.java – This program calculates the largest and smallest of three integer values.

import java.util.Scanner;

public class LargeSmall

{

public static void main(String args[])

{

// This is the work done in the housekeeping() method

// Declare and initialize variables here.

int largest; // Largest of the three values.

int smallest; // Smallest of the three values.

int num1;

int num2;

int num3;

int smallest = num1;

int largest = num2;

// This is the work done in the detailLoop() method

Scanner numbers = new Scanner(System.in);

// Prompt the user to enter 3 integer values

System.out.println(“Enter 3 integer values: “);

System.out.println(“Enter one of the following: num1, num2, or num3:”);

// Write assignments, and necessary if else statements here as appropriate

if(num2 < smallest){ smallest = num2; }else if(num3 < smallest){ smallest = num3; }else if(num3 > largest){

largest = num3;

}else if (num2 > largest){

largest = num2;

}

// This is the work done in the endOfJob() method

// Output largest and smallest number.

System.out.println(“The largest value is ” + largest);

System.out.println(“The smallest value is ” + smallest);

}

}

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?