Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package aaa;
- import java.util.InputMismatchException;
- import java.util.Scanner;
- public class Program {
- public static int askForInt(String prompt, Scanner scan) {
- boolean gotvalue = false;
- while(!gotvalue)
- {
- System.out.print(prompt);
- try {
- return scan.nextInt();
- } catch (InputMismatchException ex) {
- System.out.println("Invalid input try again");
- continue;
- }
- }
- return 0;
- }
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int gpumhz = askForInt("Please enter the clock speed (in Megahertz) of your graphics card: ", scan);
- int cpumhz = askForInt("Please enter the clock speed (in Megahertz) of your processor: ", scan);
- int corecount = askForInt("Please enter the number of cores of your processor: ", scan);
- int res = askForInt("What is the resolution of your monitor?\n\t1. 1280 x 720\n\t2. 1920 x 1080\n\t3. 2560 x 1440\n\t4. 3840 x 2160\nPlease select from the options above: ", scan);
- double multiplier = 1;
- String resolutionText = "";
- switch (res) {
- case 1:
- multiplier = 1;
- resolutionText = "1280 x 720";
- break;
- case 2:
- multiplier = 0.75;
- resolutionText = "1920 x 1080";
- break;
- case 3:
- multiplier = 0.55;
- resolutionText = "2560 x 1440";
- break;
- case 4:
- multiplier = 0.35;
- resolutionText = "3840 x 2160";
- break;
- }
- double performanceScore = (5.0 * gpumhz + corecount * cpumhz) * multiplier;
- String performanceString = "";
- if (performanceScore > 17000) {
- performanceString = "Ultra";
- } else if (performanceScore > 15000 && performanceScore <= 17000) {
- performanceString = "High";
- } else if (performanceScore > 13000 && performanceScore <= 15000) {
- performanceString = "Medium";
- } else if (performanceScore > 11000 && performanceScore <= 13000) {
- performanceString = "Low";
- } else {
- performanceString = "Unable to Play";
- }
- String idk = "Computer Hardware Graphics Quality Recommendation Tool";
- System.out.printf("\n%s\n\n", idk);
- System.out.printf("GPU Clock Speed: %d Mhz\n", gpumhz);
- System.out.printf("CPU Clock Speed: %d Mhz\n", cpumhz);
- System.out.printf("Number of cores: %d\n", corecount);
- System.out.printf("Monitor resolution: %s\n", resolutionText);
- System.out.printf("Performance Score: %,.2f\n", performanceScore);
- System.out.printf("Recommended Graphics Quality: %s\n", performanceString);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement