Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.42 KB | None | 0 0
  1. package aaa;
  2.  
  3. import java.util.InputMismatchException;
  4. import java.util.Scanner;
  5.  
  6. public class Program {
  7.  
  8.     public static int askForInt(String prompt, Scanner scan) {
  9.         boolean gotvalue = false;
  10.        
  11.         while(!gotvalue)
  12.         {
  13.             System.out.print(prompt);
  14.             try {
  15.                 return scan.nextInt();
  16.             } catch (InputMismatchException ex) {
  17.                 System.out.println("Invalid input try again");
  18.                 continue;
  19.             }
  20.         }
  21.         return 0;
  22.     }
  23.    
  24.     public static void main(String[] args) {
  25.         Scanner scan = new Scanner(System.in);
  26.        
  27.         int gpumhz = askForInt("Please enter the clock speed (in Megahertz) of your graphics card: ", scan);
  28.         int cpumhz = askForInt("Please enter the clock speed (in Megahertz) of your processor: ", scan);
  29.         int corecount = askForInt("Please enter the number of cores of your processor: ", scan);
  30.         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);
  31.  
  32.         double multiplier = 1;
  33.         String resolutionText = "";
  34.         switch (res) {
  35.         case 1:
  36.             multiplier = 1;
  37.             resolutionText = "1280 x 720";
  38.             break;
  39.         case 2:
  40.             multiplier = 0.75;
  41.             resolutionText = "1920 x 1080";
  42.             break;
  43.         case 3:
  44.             multiplier = 0.55;
  45.             resolutionText = "2560 x 1440";
  46.             break;
  47.         case 4:
  48.             multiplier = 0.35;
  49.             resolutionText = "3840 x 2160";
  50.             break;
  51.         }
  52.  
  53.         double performanceScore = (5.0 * gpumhz + corecount * cpumhz) * multiplier;
  54.         String performanceString = "";
  55.  
  56.         if (performanceScore > 17000) {
  57.             performanceString = "Ultra";
  58.         } else if (performanceScore > 15000 && performanceScore <= 17000) {
  59.             performanceString = "High";
  60.         } else if (performanceScore > 13000 && performanceScore <= 15000) {
  61.             performanceString = "Medium";
  62.         } else if (performanceScore > 11000 && performanceScore <= 13000) {
  63.             performanceString = "Low";
  64.         } else {
  65.             performanceString = "Unable to Play";
  66.         }
  67.  
  68.         String idk = "Computer Hardware Graphics Quality Recommendation Tool";
  69.         System.out.printf("\n%s\n\n", idk);
  70.  
  71.         System.out.printf("GPU Clock Speed: %d Mhz\n", gpumhz);
  72.         System.out.printf("CPU Clock Speed: %d Mhz\n", cpumhz);
  73.         System.out.printf("Number of cores: %d\n", corecount);
  74.         System.out.printf("Monitor resolution: %s\n", resolutionText);
  75.         System.out.printf("Performance Score: %,.2f\n", performanceScore);
  76.         System.out.printf("Recommended Graphics Quality: %s\n", performanceString);
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement