-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectOne.java
138 lines (116 loc) · 5.53 KB
/
ProjectOne.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import javax.swing.*;
import java.util.Scanner;
public class ProjectOne {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
// Initialize high and low scores.
double highestPScore = 0;
double lowestPScore = 0;
// Collects number of computer fo which to input information
int numberOfComputers = 0;
while (numberOfComputers <= 0) {
System.out.print("How many computers will you enter information for? ");
numberOfComputers = scan.nextInt();
}
// Prints title of program.
displayTitle();
// Gather user input and output recommended settings.
for (int i = 0; i < numberOfComputers; i++) {
int gpuClockSpeed = 0;
int cpuClockSpeed = 0;
int cpuCores = 0;
// Collects Computer information
while (!(gpuClockSpeed > 800 && gpuClockSpeed < 2000)) {
System.out.print("What is the clock speed of your GPU in MHz? ");
gpuClockSpeed = scan.nextInt();
}
while (!(cpuClockSpeed > 1000 && cpuClockSpeed < 5500)) {
System.out.print("What is the clock speed of your CPU in MHz? ");
cpuClockSpeed = scan.nextInt();
}
while (!(cpuCores > 1 && cpuCores <= 16)) {
System.out.print("How many core CPU? ");
cpuCores = scan.nextInt();
}
// Collect screen resolution.
String resolutionInput = JOptionPane.showInputDialog(null, "Screen Resolution:\n" +
"\t\t 1. 1280 x 720\n" +
"\t\t 2. 1920 x 1080\n" +
"\t\t 3. 2560 x 1440\n" +
"\t\t 4. 3840 x 2160");
int resolutionValue = Integer.parseInt(resolutionInput);
String resolution = getResolutionString(resolutionValue);
// Calculation of performance score
double multiplier = getMultiplierValue(resolutionValue);
double performanceScore = calculatePerformanceScore(gpuClockSpeed, cpuClockSpeed, cpuCores, multiplier);
String graphicSetting = getRecommendedQuality(performanceScore);
// Output of results
displayInformation(gpuClockSpeed, cpuClockSpeed, cpuCores, resolution, performanceScore, graphicSetting);
// Determine highest and lowest performance scores.
if (i == 1) {
highestPScore = performanceScore;
lowestPScore = performanceScore;
} else {
if (performanceScore > highestPScore)
highestPScore = performanceScore;
else if (performanceScore < lowestPScore)
lowestPScore = performanceScore;
else
continue;
}
}
System.out.println("\n");
System.out.printf("The highest performance score was: %,.3f", highestPScore);
System.out.print("\n");
System.out.printf("The lowest performance score was: %,.3f", lowestPScore);
}
private static void displayTitle() {
// Prints title of program.
String title = "Computer Hardware Graphics Quality Recommendation Tool";
System.out.println("\n");
System.out.println(title);
System.out.println("\n");
}
private static String getResolutionString(int value) {
// Stores resolution as a string.
String[] resolution = {"1280 x 720", "1920 x 1080", "2560 x 1440", "3840 x 2160"};
return resolution[value];
}
private static double getMultiplierValue(int value) {
double[] multiplier = {0, 1, .75, .55, .35};
return multiplier[value];
}
private static double calculatePerformanceScore(int gpuClockSpeed, int cpuClockSpeed, int cpuCores, double multiplier) {
// Calculation of performance score
double performanceScore;
performanceScore = ((5 * gpuClockSpeed) + (cpuCores * cpuClockSpeed))
* multiplier;
return performanceScore;
}
private static String getRecommendedQuality(double performanceScore) {
// Determine graphic setting recommendation based on performance score.
String graphicSetting;
if (performanceScore > 17_000)
graphicSetting = "Ultra";
else if (performanceScore > 15_000 && performanceScore <= 17_000)
graphicSetting = "High";
else if (performanceScore > 13_000 && performanceScore <= 15_000)
graphicSetting = "Medium";
else if (performanceScore > 11_000 && performanceScore <= 13_000)
graphicSetting = "Low";
else
graphicSetting = "Unable to Play";
return graphicSetting;
}
private static void displayInformation(int gpuClockSpeed, int cpuClockSpeed, int cpuCores, String resolution, double performanceScore, String graphicSetting) {
// Output of results
System.out.println("\n");
System.out.println(String.format("GPU Clock Speed:\t\t %sMHz", gpuClockSpeed));
System.out.println(String.format("CPU Clock Speed:\t\t %sMHz", cpuClockSpeed));
System.out.println(String.format("Number of cores:\t\t %s", cpuCores));
System.out.println(String.format("Monitor Resolution:\t\t %s", resolution));
System.out.println(String.format("Performance Score:\t\t %,.3f", performanceScore));
System.out.println(String.format("Recommended Settings:\t %s", graphicSetting));
System.out.println("\n");
}
}