-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLargestNumber.java
More file actions
50 lines (31 loc) · 1.08 KB
/
LargestNumber.java
File metadata and controls
50 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.util.Scanner;
public class LargestNumber{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter a number : ");
int firstNumber = input.nextInt();
System.out.print("Enter a number : ");
int secondNumber = input.nextInt();
System.out.print("Enter a number : ");
int thirdNumber = input.nextInt();
int largestNumber = firstNumber;
if(largestNumber < secondNumber){
largestNumber = secondNumber;
}
if(largestNumber < thirdNumber){
largestNumber = thirdNumber;
}
System.out.printf("%d is the largest number", largestNumber);
}
}
/*
check the largest number in the user input
prompt the user to enter three numbers
create a variable that reads the users input
create a new variable and assign the first user's input as the value
check if the new variable is less than the second input
reassign the second input as a value to the new variable
check again if the new variable is less than the third input
reassign the new variable to the third input
print"the largest number"
*/