-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDistanceTest.java
More file actions
27 lines (21 loc) · 902 Bytes
/
DistanceTest.java
File metadata and controls
27 lines (21 loc) · 902 Bytes
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
import java.util.Scanner;
public class DistanceTest {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the first feet");
int feet1 = scanner.nextInt();
System.out.println("Enter the first inch");
int inch1 = scanner.nextInt();
Distance distance1 = new Distance();
distance1.set(feet1, inch1);// Taking the input
System.out.println("Enter the second feet");
int feet2 = scanner.nextInt();
System.out.println("Enter the second inch");
int inch2 = scanner.nextInt();
Distance distance2 = new Distance();
distance2.set(feet2, inch2);
Distance distancesum = new Distance();
distancesum = Distance.sum(distance1, distance2);// Calling the sum function by the object of Distance
System.out.println("New Distance is " + distancesum.feet + " feet " + distancesum.inches + " inch");
}
}