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
so, I assume you have some algorithm or formula to calculate the performance score and graphics quality from the given data?
Looks fairly simple. For each computer, read in the data and display it and the results. Compare the score to the existing high/low scores and update them if necessary.
After the input terminates, display the high and low scores.
Pretty much just I/O and minimal calculation. Where do you have trouble?
To modify the code from Project 1 to read and process information from a file named Computers.txt, follow these steps:
1. Open the Computers.txt file using file input/output operations in your programming language of choice.
- Read the contents of the file and store it in a string or a list/array, depending on how the information is structured in the file.
- Make sure to handle any errors that may occur during file operations.
2. Update the code from Project 1 to handle the new input format.
- Parse the information from the file and extract the GPU clock speed, CPU clock speed, number of cores, and monitor resolution for each computer.
- Convert the monitor resolution from the numeric representation (1, 2, 3, or 4) to the corresponding menu options from Project 1 (1280 x 720, 1920 x 1080, etc.).
3. Display the title at the top of the output, just like in Project 1.
- This should be a simple print statement to display the title.
4. Process and display the information for each computer in the file.
- For each computer, display the GPU clock speed, CPU clock speed, number of cores, monitor resolution, performance score, and recommended graphics quality.
- Calculate the performance score using the formulas from Project 1 and round it to three decimal places.
- Determine the recommended graphics quality based on the performance score using the criteria from Project 1.
- Use print statements to display the information for each computer.
5. Keep track of the highest and lowest performance scores.
- During the iteration over the computers, update the highest and lowest performance scores accordingly.
- At the end of the output, display the highest and lowest performance scores using print statements.
Ensure that your code is thoroughly documented with comments to explain the purpose of each section and any specific steps that may not be immediately clear.