Playing a video game on a computer can give different experiences based on the performance capabilities of the computer’s hardware (typically processor and graphics card – among other things).
Developers of a new game will typically have “recommended” specifications for the computer hardware that is required to run their games on a variety of graphics settings (the faster the hardware, the higher the graphics quality).
You are being tasked to create a program that will tell a gamer what graphics quality they will be able to run a newly developed video game on, based on the specifications of their computer’s hardware.
Note: When declaring variables, initialize all variables to avoid the following error message: variable might not have been initialized.
Step 1:
Ask the user to enter the clock speed (in Megahertz) of their graphics card (GPU). This is an indicator of how fast their graphics card is.
Note: Example GPU clock speeds range from 1000 MHz to 2000 MHz
Step 2:
Ask the user to enter the clock speed (in Megahertz) of their processor (CPU). This is an indicator of how fast their processor is.
Note: Example CPU clock speeds range from 3000 MHz to 5000 MHz
Step 3:
Ask the user to enter the number of cores that their processor (CPU) has. The more cores a processor has, the more work it can do.
Note: Example CPUs have between 2-8 cores
Step 4:
Display a menu and ask the user to select the resolution of their monitor. The menu should contain the following options:
1280 x 720
1920 x 1080
2560 x 1440
3840 x 2160
Note: Resolution consists of two numbers separated by an ‘x’. The first number is the number of pixels in the width of the screen. The second number is the number of pixels in the height of the screen.
Step 5:
Assign a “multiplier” value based on the monitor resolution by using the following table:
Resolution
Multiplier
1280 x 720
1
1920 x 1080
.75
2560 x 1440
.55
3840 x 2160
.35
Step 6:
Calculate a “performance score” by using the following formula:
Performance Score = ((5 * GPU Clock Speed) + (Number of Cores * CPU Clock Speed)) * Multiplier
Example: A GPU with a clock speed of 1200MHz, a 4-core CPU with a clock speed of 4200 MHz, and a 1280 x 720 resolution monitor would have a Performance Score calculation of:
Performance Score = ((5 * 1200) + (4 * 4200)) * 1 = 22800
Step 7:
Determine the recommended graphics quality that the hardware can support by using the information in the table below.
Performance Score
Recommended Graphics Quality
Over 17,000
Ultra
Over 15,000 but not more than 17,000
High
Over 13,000 but not more than 15,000
Medium
Over 11,000 but not more than 13,000
Low
11,000 or less
Unable to Play
Step 8:
Create a String object in memory to hold the text “Computer Hardware Graphics Quality Recommendation Tool”. Display that text at the top of the output (See sample Input and Output below).
Step 9:
Display the following output (See sample Input and Output below):
The GPU clock speed
The CPU clock speed
The number of cores
The Monitor Resolution
The Performance Score (rounded to three decimal places)
The Recommended Graphics Quality
The code you submit should be thoroughly documented with comments where appropriate.
Sample Input and Output (user input is in bold)
Please enter the clock speed (in Megahertz) of your graphics card: 1000
Please enter the clock speed (in Megahertz) of your processor: 3000
Please enter the number of cores of your processor: 2
What is the resolution of your monitor?
1. 1280 x 720
2. 1920 x 1080
3. 2560 x 1440
4. 3840 x 2160
Please select from the options above: 1
Computer Hardware Graphics Quality Recommendation Tool
GPU Clock Speed: 1000 MHz
CPU Clock Speed: 3000 MHz
Number of cores: 2
Monitor Resolution: 1280 x 720
Performance Score: 11000.000
Recommended Graphics Quality: Unable to Play
____________________________________________________________________________________________________________________________________
Project 2 is a continuation of Project 1. Modify the code from Project 1 to read and process information from a file named Computers.txt.
The text file contains profiles about a set of computers. Each computer should be processed. The text file contains information in the following order:
The GPU clock speed
The CPU clock speed
The number of cores
The Monitor Resolution (will be represented as 1,2,3, or 4 corresponding to the menu options in Project 1 – so ‘1’ means ‘1280 x 720’, ‘2’ means ‘1920 x 1080’, and so on)
Display the title once at the top of the output, just like in Project 1.
After displaying the title, the program should process all of the information in the file and display the following output for each computer in the file:
The GPU clock speed
The CPU clock speed
The number of cores
The Monitor Resolution
The Performance Score (rounded to three decimal places)
The Recommended Graphics Quality
At the end of the output, the program should display the highest and lowest performance score.
The code you submit should be thoroughly documented with comments where appropriate.
Sample Input and Output
Computer Hardware Graphics Quality Recommendation Tool
GPU Clock Speed: 1000 MHz
CPU Clock Speed: 3000 MHz
Number of cores: 4
Monitor Resolution: 1280 x 720
Performance Score: 17000.000
Recommended Graphics Quality: High
GPU Clock Speed: 1250 MHz
CPU Clock Speed: 3200 MHz
Number of cores: 4
Monitor Resolution: 2560 x 1440
Performance Score: 10477.500
Recommended Graphics Quality: Unable to Play
GPU Clock Speed: 1675 MHz
CPU Clock Speed: 3950 MHz
Number of cores: 6
Monitor Resolution: 3840 x 2160
Performance Score: 11226.250
Recommended Graphics Quality: Low
GPU Clock Speed: 1800 MHz
CPU Clock Speed: 4300 MHz
Number of cores: 4
Monitor Resolution: 1920 x 1080
Performance Score: 19650.000
Recommended Graphics Quality: Ultra
GPU Clock Speed: 1600 MHz
CPU Clock Speed: 3500 MHz
Number of cores: 3
Monitor Resolution: 1920 x 1080
Performance Score: 13875.000
Recommended Graphics Quality: Medium
The highest performance score was: 19650.000
The lowest performance score was: 10477.500
____________________________________________________________________________________________________________________________________
Modify the code from Project 2 to make it modular.
In addition to the main method, your code must include the following static methods:
Method 1 - displayTitle
A void method that displays the title
Method 2 – getResolutionString
A method that accepts an integer value (1, 2, 3, or 4) that denotes the monitor resolution. The method should return the appropriate String representation of the monitor resolution. For example, if the method is passed an integer value of 1, it should return a String with a value of “1280 x 720”. (See Step 4 of Project 1)
Method 3 – getMultiplierValue
A method that accepts an integer value (1, 2, 3, or 4) that denotes the monitor resolution and returns the appropriate “multiplier” value. (See Step 5 of Project 1)
Method 4 - calculatePerformanceScore
A method that accepts the GPU clock speed, CPU clock speed, the number of cores, and the multiplier value, and calculates and returns the performance score. (See Step 6 of Project 1)
Method 5 – getRecommendedQuality
A method that accepts a performance score as an argument and returns the recommended graphics quality. (See Step 7 of Project 1)
Method 6 - displayInformation
A void method that prints out the information for a single computer. The output should look exactly the same as the output for Project 2. The method should accept only the arguments necessary to print out the information. (See Step 9 of Project 1)
Each of the above methods should match the naming and parameter requirements exactly. Do not rename the method, or add/remove arguments to the method.
At the end of the output, the program should display the highest and lowest performance score.
The code that you submit should be thoroughly documented with comments where appropriate (this includes documentation for each method).
Sample Input and Output
Computer Hardware Graphics Quality Recommendation Tool
GPU Clock Speed: 1000 MHz
CPU Clock Speed: 3000 MHz
Number of cores: 4
Monitor Resolution: 1280 x 720
Performance Score: 17000.000
Recommended Graphics Quality: High
GPU Clock Speed: 1250 MHz
CPU Clock Speed: 3200 MHz
Number of cores: 4
Monitor Resolution: 2560 x 1440
Performance Score: 10477.500
Recommended Graphics Quality: Unable to Play
GPU Clock Speed: 1675 MHz
CPU Clock Speed: 3950 MHz
Number of cores: 6
Monitor Resolution: 3840 x 2160
Performance Score: 11226.250
Recommended Graphics Quality: Low
GPU Clock Speed: 1800 MHz
CPU Clock Speed: 4300 MHz
Number of cores: 4
Monitor Resolution: 1920 x 1080
Performance Score: 19650.000
Recommended Graphics Quality: Ultra
GPU Clock Speed: 1600 MHz
CPU Clock Speed: 3500 MHz
Number of cores: 3
Monitor Resolution: 1920 x 1080
Performance Score: 13875.000
Recommended Graphics Quality: Medium
The highest performance score was: 19650.000
The lowest performance score was: 10477.500
____________________________________________________________________________________________________________________________________
The programs are done in Java, I have little time to do them, and they're due on Sunday night.
Source Code:
Project-1:
package practice;
import java.util.*;
import java.io.*;
public class Practice {
public static void displayTitle()
{
String title = "Computer Hardware Graphics Quality Recommendation
Tool";
System.out.println(title);
}
public static String getResolutionString(int num)
{
String resolution;
switch(num)
{
case 1: resolution = "1280 x 720";
break;
case 2: resolution = "1920 x 1080";
break;
case 3: resolution = "2560 x 1440";
break;
case 4: resolution = "3840 x 2160";
break;
default : resolution = "Wrong input";
break;
}
return resolution;
}
public static double getMultiplierValue(int num)
{
double multiplier;
switch(num)
{
case 1: multiplier = 1.0;
break;
case 2: multiplier = 0.75;
break;
case 3: multiplier = 0.55;
break;
case 4: multiplier = 0.35;
break;
default : multiplier = 0;
break;
}
return multiplier;
}
public static double calculatePerformanceScore(int gpuClockSpeed,
int cpuClockSpeed, int numOfCores, double multiplier)
{
double gpuPerformance = 5.0*gpuClockSpeed;
double cpuPerformance = numOfCores*cpuClockSpeed*1.0;
double performanceScore = (gpuPerformance +
cpuPerformance)*multiplier;
performanceScore = Math.round(performanceScore*1000)/1000.0;
return performanceScore;
}
public static String getRecommendedQuality(double
performanceScore)
{
if(performanceScore > 17000.0)
{
return "Ultra";
}
else if(performanceScore > 15000.0)
{
return "High";
}
else if(performanceScore > 13000.0)
{
return "Medium";
}
else if(performanceScore > 11000.0)
{
return "Low";
}
else
{
return "Unable to Play";
}
}
public static void displayInformation(int gpuClockSpeed, int
cpuClockSpeed, int numOfCores, String resolution, double
performanceScore, String recommendedQuality)
{
System.out.println("GPU Clock Speed: " + gpuClockSpeed + "
MHz");
System.out.println("CPU Clock Speed: " + cpuClockSpeed + "
MHz");
System.out.println("Number of cores: " + numOfCores);
System.out.println("Monitor Resolution: " + resolution);
System.out.println("Performance Score: " + performanceScore);
System.out.println("Recommended Graphics Quality: "+
recommendedQuality);
}
public static void main(String args[])
{
int gpuClockSpeed, cpuClockSpeed, numOfCores, res;
double multiplier, performanceScore;
String resolution, recommendedQuality;
Scanner scanner = new Scanner(System.in);
System.out.print("Please enter the clock speed (in Megahertz) of
your graphics card: ");
gpuClockSpeed = scanner.nextInt();
System.out.print("Please enter the clock speed (in Megahertz) of
your processor: ");
cpuClockSpeed = scanner.nextInt();
System.out.print("Please enter the number of cores of your
processor: ");
numOfCores = scanner.nextInt();
System.out.println("What is the resolution of your
monitor?");
System.out.println("\t1. 1280 x 720");
System.out.println("\t2. 1920 x 1080");
System.out.println("\t3. 2560 x 1440");
System.out.println("\t4. 3840 x 2160");
System.out.print("Please select from the options above: ");
res = scanner.nextInt();
resolution = getResolutionString(res);
multiplier = getMultiplierValue(res);
performanceScore = calculatePerformanceScore(gpuClockSpeed,
cpuClockSpeed, numOfCores, multiplier);
recommendedQuality = getRecommendedQuality(performanceScore);
displayTitle();
displayInformation(gpuClockSpeed, cpuClockSpeed, numOfCores,
resolution, performanceScore, recommendedQuality);
}
}
Project-2:
package practice;
import java.util.*;
import java.io.*;
public class Practice {
public static void displayTitle()
{
String title = "Computer Hardware Graphics Quality Recommendation
Tool";
System.out.println(title);
}
public static String getResolutionString(int num)
{
String resolution;
switch(num)
{
case 1: resolution = "1280 x 720";
break;
case 2: resolution = "1920 x 1080";
break;
case 3: resolution = "2560 x 1440";
break;
case 4: resolution = "3840 x 2160";
break;
default : resolution = "Wrong input";
break;
}
return resolution;
}
public static double getMultiplierValue(int num)
{
double multiplier;
switch(num)
{
case 1: multiplier = 1.0;
break;
case 2: multiplier = 0.75;
break;
case 3: multiplier = 0.55;
break;
case 4: multiplier = 0.35;
break;
default : multiplier = 0;
break;
}
return multiplier;
}
public static double calculatePerformanceScore(int gpuClockSpeed,
int cpuClockSpeed, int numOfCores, double multiplier)
{
double gpuPerformance = 5.0*gpuClockSpeed;
double cpuPerformance = numOfCores*cpuClockSpeed*1.0;
double performanceScore = (gpuPerformance +
cpuPerformance)*multiplier;
performanceScore =
Math.round(performanceScore*1000.0)/1000.0;
return performanceScore;
}
public static String getRecommendedQuality(double
performanceScore)
{
if(performanceScore > 17000.0)
{
return "Ultra";
}
else if(performanceScore > 15000.0)
{
return "High";
}
else if(performanceScore > 13000.0)
{
return "Medium";
}
else if(performanceScore > 11000.0)
{
return "Low";
}
else
{
return "Unable to Play";
}
}
public static void displayInformation(int gpuClockSpeed, int
cpuClockSpeed, int numOfCores, String resolution, double
performanceScore, String recommendedQuality)
{
System.out.println("GPU Clock Speed: " + gpuClockSpeed + "
MHz");
System.out.println("CPU Clock Speed: " + cpuClockSpeed + "
MHz");
System.out.println("Number of cores: " + numOfCores);
System.out.println("Monitor Resolution: " + resolution);
System.out.println("Performance Score: " + performanceScore);
System.out.println("Recommended Graphics Quality: "+
recommendedQuality);
}
public static void main(String args[]) throws IOException
{
int gpuClockSpeed=0, cpuClockSpeed=0, numOfCores =0, res = 0
;
double multiplier, performanceScore;
String resolution, recommendedQuality;
File file = new
File("C:\\Users\\kasar\\Documents\\NetBeansProjects\\practice\\src\\practice\\Computers.txt");
BufferedReader br = new BufferedReader(new
FileReader(file));
String val;
int cnt = 0;
displayTitle();
double maxPerformanceScore = -100.0;
double minPerformanceScore = 1000000000.0;
while ((val = br.readLine()) != null)
{
cnt += 1;
cnt %= 4;
if(cnt == 1)
{
gpuClockSpeed = Integer.valueOf(val);
}
else if(cnt == 2)
{
cpuClockSpeed = Integer.valueOf(val);
}
else if(cnt == 3)
{
numOfCores = Integer.valueOf(val);
}
else if(cnt == 0)
{
res = Integer.valueOf(val);
}
if(cnt == 0)
{
resolution = getResolutionString(res);
multiplier = getMultiplierValue(res);
performanceScore = calculatePerformanceScore(gpuClockSpeed,
cpuClockSpeed, numOfCores, multiplier);
recommendedQuality = getRecommendedQuality(performanceScore);
displayInformation(gpuClockSpeed, cpuClockSpeed, numOfCores,
resolution, performanceScore, recommendedQuality);
if(performanceScore > maxPerformanceScore)
{
maxPerformanceScore = performanceScore;
}
if(performanceScore < minPerformanceScore)
{
minPerformanceScore = performanceScore;
}
}
}
System.out.println("The highest performance score was:
"+maxPerformanceScore);
System.out.println("The lowest performance score was:
"+minPerformanceScore);
}
}
Computers.txt file:
1000
3000
4
1
1250
3200
4
3
1675
3950
6
4
1800
4300
4
2
1600
3500
3
2
Outputs: Output is as expected and given in the question.
Sample:
Computer Hardware Graphics Quality Recommendation Tool
GPU Clock Speed: 1000 MHz
CPU Clock Speed: 3000 MHz
Number of cores: 4
Monitor Resolution: 1280 x 720
Performance Score: 17000.0
Recommended Graphics Quality: High
GPU Clock Speed: 1250 MHz
CPU Clock Speed: 3200 MHz
Number of cores: 4
Monitor Resolution: 2560 x 1440
Performance Score: 10477.5
Recommended Graphics Quality: Unable to Play
GPU Clock Speed: 1675 MHz
CPU Clock Speed: 3950 MHz
Number of cores: 6
Monitor Resolution: 3840 x 2160
Performance Score: 11226.25
Recommended Graphics Quality: Low
GPU Clock Speed: 1800 MHz
CPU Clock Speed: 4300 MHz
Number of cores: 4
Monitor Resolution: 1920 x 1080
Performance Score: 19650.0
Recommended Graphics Quality: Ultra
GPU Clock Speed: 1600 MHz
CPU Clock Speed: 3500 MHz
Number of cores: 3
Monitor Resolution: 1920 x 1080
Performance Score: 13875.0
Recommended Graphics Quality: Medium
The highest performance score was: 19650.0
The lowest performance score was: 10477.5
Playing a video game on a computer can give different experiences based on the performance capabi...