-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram9.java
More file actions
37 lines (33 loc) · 1.22 KB
/
program9.java
File metadata and controls
37 lines (33 loc) · 1.22 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
// Define the Compute interface
interface Compute {
void convert(double input);
}
// Class to convert Gigabytes to Bytes
class GigabytesToBytes implements Compute {
@Override
public void convert(double input) {
double bytes = input * 1_073_741_824; // 1 GB = 2^30 bytes
System.out.println(input + " Gigabytes is " + bytes + " Bytes.");
}
}
// Class to convert Euros to Rupees
class EuroToRupees implements Compute {
@Override
public void convert(double input) {
double conversionRate = 90.0; // Example conversion rate
double rupees = input * conversionRate;
System.out.println(input + " Euros is " + rupees + " Rupees.");
}
}
// Main class to demonstrate the conversions
public class program9 {
public static void main(String[] args) {
// Create objects of the conversion classes
Compute gbToBytes = new GigabytesToBytes();
Compute euroToRupees = new EuroToRupees();
// Perform conversions
System.out.println("Conversion Demonstrations:");
gbToBytes.convert(2.5); // Example: Convert 2.5 GB to Bytes
euroToRupees.convert(100); // Example: Convert 100 Euros to Rupees
}
}