#include <iostream>
using namespace std;
int main()
{
int GPUspeed = 0, CPUspeed = 0, cores = 0, resolutionChoice = 0;
float mutliplier = 0.0, performanceSCore = 0.0;
string graphicsQuality = "", headerText = "Computer Hardware Graphics Quality Recommendation Tool";
{1280, 720},
{1920, 1080},
{2560, 1440},
{3840, 2160}
};
cout<<"Please enter the clock speed (in Megahertz) of your graphics card:";
cin>>GPUspeed;
cout<<"Please enter the clock speed (in Megahertz) of your processor:";
cin>>CPUspeed;
cout<<"Please enter the number of cores of your processor:";
cin>>cores;
//display resolutionMatrix
cout<<"What is the resolution of your monitor?" <<endl;
for(int i=0; i<4; i++);
cout<<i+1<<"."<<resolutionMatrix[i][0]<<"x"<<resolutionMatrix[i][1]<<endl;
cout<<"Please select from the options above:";
cin>>resolutionChoice;
switch(resolutionChoice){
case 1: multiplier = 1;
break;
case 2: multiplier = 0.75;
break;
case 3: multiplier = 0.55;
break;
case 4: multiplier = 0.35;
break;
default : cout<<"Wrong choice input!";
exit(0);
}
//calulate performanceScore
//((5 * GPU Clock Speed) + (Number of Cores * CPU Clock Speed)) * Multiplier
performanceScore = ((5 * GPUspeed) + (cores*CPUspeed))*multiplier;
//determine graphicsQuality
if(performanceScore >=17000)
graphicsQuality="Ultra";
else if(performanceScore >=15000)
graphicsQuality="High";
else if(performanceScore >=13000)
graphicsQuality="Medium";
else if(performanceScore >=11000)
graphicsQuality="Low";
else
graphicsQuality="Unable to play.";
//output results
cout<<headerText<<endl;
cout<<"GPU Clock Speed: " <<GPUspeed<<" MHz"<<endl;
cout<<"CPU Clock Speed: " <<CPUspeed<< "MHz"<<endl;
cout<<"Number of cores: " <<cores<<endl;
cout<<"Monitor Resolution: " <<resolutionMatrix[resolutionChoice-1][0]<<"x"<<resolutionMatrix
[resolutionChoice-1][1]<<endl;
cout<<"Performance Score:" <<performanceScore<<endl;
cout<<"Recommended Graphics Quality: " <<graphicsQuality<<endl;
return 0;
}
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
is this c++ ?
To calculate the performance score and recommend graphics quality for each computer in the text file, we can follow these steps:
1. Start by reading the input file.
2. Declare and initialize variables for the highest and lowest performance scores.
3. Display the title "Computer Hardware Graphics Quality Recommendation Tool".
4. Inside a loop, read the GPU clock speed, CPU clock speed, number of cores, and monitor resolution for each computer.
5. Calculate the performance score using the formula: ((5 * GPU Clock Speed) + (Number of Cores * CPU Clock Speed)) * Multiplier. Set the multiplier based on the chosen monitor resolution.
6. Determine the graphics quality based on the performance score. Use if-else statements to set the graphics quality as "Ultra", "High", "Medium", "Low", or "Unable to Play".
7. Display the computer's information, including the GPU clock speed, CPU clock speed, number of cores, monitor resolution, performance score, and recommended graphics quality.
8. Update the highest and lowest performance scores if necessary.
9. After the loop, display the highest and lowest performance scores.
Here's an example of how the code could be implemented:
```cpp
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string inputFileName = "computers.txt";
ifstream inputFile(inputFileName);
int GPUspeed = 0, CPUspeed = 0, cores = 0, resolutionChoice = 0;
float multiplier = 0.0, performanceScore = 0.0;
string graphicsQuality = "", headerText = "Computer Hardware Graphics Quality Recommendation Tool";
// Variables for highest and lowest performance scores
float highestScore = 0.0, lowestScore = INT_MAX;
if (!inputFile)
{
cerr << "Failed to open the input file." << endl;
return 1;
}
// Display title
cout << headerText << endl;
// Process each computer in the file
while (inputFile >> GPUspeed >> CPUspeed >> cores >> resolutionChoice)
{
// Display computer information
cout << "GPU Clock Speed: " << GPUspeed << " MHz" << endl;
cout << "CPU Clock Speed: " << CPUspeed << " MHz" << endl;
cout << "Number of cores: " << cores << endl;
cout << "Monitor Resolution: ";
// Determine the multiplier and display the monitor resolution
switch (resolutionChoice)
{
case 1:
multiplier = 1;
cout << "1280 x 720";
break;
case 2:
multiplier = 0.75;
cout << "1920 x 1080";
break;
case 3:
multiplier = 0.55;
cout << "2560 x 1440";
break;
case 4:
multiplier = 0.35;
cout << "3840 x 2160";
break;
default:
cerr << "Wrong choice input!" << endl;
exit(0);
}
cout << endl;
// Calculate the performance score
performanceScore = ((5 * GPUspeed) + (cores * CPUspeed)) * multiplier;
// Determine graphics quality
if (performanceScore >= 17000)
graphicsQuality = "Ultra";
else if (performanceScore >= 15000)
graphicsQuality = "High";
else if (performanceScore >= 13000)
graphicsQuality = "Medium";
else if (performanceScore >= 11000)
graphicsQuality = "Low";
else
graphicsQuality = "Unable to Play";
// Display performance score and recommended graphics quality
cout << "Performance Score: " << performanceScore << endl;
cout << "Recommended Graphics Quality: " << graphicsQuality << endl;
// Update highest and lowest performance scores
if (performanceScore > highestScore)
highestScore = performanceScore;
if (performanceScore < lowestScore)
lowestScore = performanceScore;
cout << endl;
}
inputFile.close();
// Display highest and lowest performance scores
cout << "The highest performance score was: " << highestScore << endl;
cout << "The lowest performance score was: " << lowestScore << endl;
return 0;
}
```
Make sure to replace "computers.txt" with the actual file name and provide the correct file path if necessary.
Note: This code assumes that the input file is in the correct format, with the GPU clock speed, CPU clock speed, number of cores, and monitor resolution listed in that order for each computer.