-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExecutionTime.java
More file actions
47 lines (34 loc) · 1.46 KB
/
ExecutionTime.java
File metadata and controls
47 lines (34 loc) · 1.46 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
import java.util.Scanner;
public class ExecutionTime {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Please type in the instruction count. " +
"With a space, please add the CPI. " +
"Again with a space, add the clock time. " +
"Finally with a space, add the Reference Time");
double count = input.nextDouble();
double cpi = input.nextDouble();
double cycle = input.nextDouble();
double spec = input.nextDouble();
printTable(count, cpi, cycle, spec);
}
private static void printTable (double string1, double string2,
double string3, double spec) {
System.out.println("--------- " + "--------- " + "--------- " + "--------- " + "--------- " + " ---------");
double exTime = string1 * string2 * string3;
double refTime = spec/exTime;
System.out.print(string1);
System.out.print(" ");
System.out.print(string2);
System.out.print(" ");
System.out.print(string3);
System.out.print(" ");
System.out.printf("%.2f", exTime);
System.out.print(" ");
System.out.printf("%.2f", spec);
System.out.print(" ");
System.out.print(refTime);
System.out.println("\nExecution time is " + exTime);
System.out.println("SPECratio is " + refTime);
}
}