Question: Coding Language: Java The code prompts the user to input a value for x and for y. It then prints the smallest value contained in

Coding Language: Java

The code prompts the user to input a value for x and for y. It then prints the smallest value contained in the variables x and y. Modify the code so that it prompts the user to enter a third value for a variable z. Rewrite the logic so that the program prints out the smallest value contained in x, y, and z.

import java.util.*;
public class Lab { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Enter a value for x:"); int x = scan.nextInt(); System.out.println("Enter a value for y:"); int y = scan.nextInt(); int minimum; if (x < y) { minimum = x; } else { minimum = y; } System.out.println("The smallest value is " + minimum); } // end main method } // end class Lab 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!