-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest Rectangle
75 lines (61 loc) · 1.94 KB
/
Test Rectangle
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
import java.util.Scanner;
public class TestRectangle {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int choice;
int length = 0;
int width = 0;
int results;
Rectangle myRectangle = new Rectangle();
//the menu
System.out.println("Lisa Tidball - Assignment7\n");
System.out.println("1. Set length");
System.out.println("2. Set Width");
System.out.println("3. Exit");
System.out.println("Choice:");
choice = input.nextInt();
switch (choice)
{
//results of the choice
case 1:
{
System.out.printf("What is the length?");
length = input.nextInt();
myRectangle.setLength(length); //method in class cannot be applied to given types
myRectangle.getArea();
myRectangle.getPerimeter();
System.out.println("1. Set length");
System.out.println("2. Set Width");
System.out.println("3. Exit");
System.out.println("Choice:");
choice = input.nextInt();
break;
}
case 2:
{
System.out.printf("What is the width?");
width = input.nextInt();
myRectangle.setWidth(width);
myRectangle.getArea();
myRectangle.getPerimeter();
System.out.println("1. Set length");
System.out.println("2. Set Width");
System.out.println("3. Exit");
System.out.println("Choice:");
choice = input.nextInt();
break;
}
case 3:
{
System.out.printf("Have a wonderful day");
break;
}
default:
{
System.out.println("Please enter a number of 1-3");
}
results = width * length;
System.out.println(results);
}
}//end main
}