-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmgwright_SmallestLargest.java
79 lines (62 loc) · 1.75 KB
/
mgwright_SmallestLargest.java
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Name : Matthew Wright
// Class : 1400-005
// Program # : 5
// Due Date : February 13th, 2009 @ 12 am
//
// Honor Pledge : On my honor as a student of the University
// of Nebraska at Omaha, I have neither given nor received
// unauthorized help on this homework assignment.
//
// NAME: Matthew Wright
// NUID: 832
// EMAIL: [email protected]
// Partners: NONE
// Description: This program takes 6 numbers and produces the smallest and the largest of the group
import java.util.Scanner;
public class mgwright_SmallestLargest
{
public static void main( String args[] )
{
//Declare variables and Scanner
int value;
int smallest;
int largest;
Scanner in = new Scanner( System.in );
//Accept and input, then compare to smallest and largest
System.out.print("Please enter the first integer: ");
value = in.nextInt();
smallest = value;
largest = value;
System.out.print("Please enter the second integer: ");
value = in.nextInt();
if(value < smallest)
smallest = value;
if(value > largest)
largest = value;
System.out.print("Please enter the third integer: ");
value = in.nextInt();
if(value < smallest)
smallest = value;
if(value > largest)
largest = value;
System.out.print("Please enter the fourth integer: ");
value = in.nextInt();
if(value < smallest)
smallest = value;
if(value > largest)
largest = value;
System.out.print("Please enter the fifth integer: ");
value = in.nextInt();
if(value < smallest)
smallest = value;
if(value > largest)
largest = value;
System.out.print("Please enter the sixth integer: ");
value = in.nextInt();
if(value < smallest)
smallest = value;
if(value > largest)
largest = value;
System.out.printf("%d:%d\n", largest, smallest);
}
}