Understanding if-elseStatements
Summary
In this lab, you will complete a prewritten Java program thatcomputes the largest and smallest of three integer values. Thethree values are –50, 53, and78.
Instructions
- Two variables named largest and smallest are declared for you.Use these variables to store the largest and smallest of the threeinteger values. You must decide what other variables you will needand initialize them if appropriate.
- Write the rest of the program using assignment statements, ifstatements, or if-else statements as appropriate. There arecomments in the code that tell you where you should write yourstatements. The output statement is written for you.
- Execute the program. Your output should be:
The largest value is 78The smallest value is −50
Grading
When you have completed your program, click theSubmit button to record your score.
// LargeSmall.java - This program calculates the largest andsmallest of three integer values.
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.
// This is the work done in the detailLoop() method
//Write assignment, if, or if else statements here asappropriate.
// 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);
}
}