[java] LargestNum
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- /*The purpose of this program is to identify the
- largest number out of three ints entered by the user.
- Created w/ VSCode
- */
- import java.util.Scanner;
- public class LargestNum {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- int num1;
- int num2;
- int num3;
- System.out.println("Enter a number");
- num1 = keyboard.nextInt();
- System.out.println("Enter another number");
- num2 = keyboard.nextInt();
- System.out.println("Enter a third number");
- num3 = keyboard.nextInt();
- // TO DO: Complete the following code to determine which of the three numbers are the largest
- //Make note of any assumptions that you are making
- if ( ) { //fill in this if statement (in parens), for the condition where num1 is the largest
- System.out.println(num1+" is the largest num.");
- }
- else if ( ) { //fill in this if statement, for the condition where num2 is the largest
- System.out.println(num2 +" is the largest num.");
- }
- else { //since num1 and num2 weren't largest, num3 is largest by default
- System.out.println(num3 +" is the largest num.");
- }
- keyboard.close();
- }
- }
Editor
You can edit this paste and save as new:
File Description
- LargestNum
- Paste Code
- 28 Sep-2022
- 1.25 Kb
You can Share it:
Latest Code Pastes