samedi 30 mars 2019

Part of println not showing expected result

I was given this assignment to do and I have gotten all my variables values and calculated some stuff. However I couldn't show the System.out.println("Recommended Graphics Quality: " + performance); it would not show the string performance at all.

File file = new File("Computers.txt");//Grabs file and scans it
  try{
     Scanner inputFile = new Scanner(file);//opens the file
     gpuSpeed = inputFile.nextInt();
     cpuSpeed = inputFile.nextInt();
     numCore = inputFile.nextInt();
     choiceMonitor = inputFile.nextInt();
  } catch (FileNotFoundException e){
     System.out.println("File not found");
  }

switch(choiceMonitor)
{
  case 1:
     performanceScore = ((5 * gpuSpeed) + (numCore * cpuSpeed)) * 1;
     monitor = "1280 x 720";
     break;

  case 2: 
     performanceScore = ((5 * gpuSpeed) + (numCore * cpuSpeed)) * .75;
     monitor = "1920 x 1080";
     break;

  case 3: 
     performanceScore = ((5 * gpuSpeed) + (numCore * cpuSpeed)) * .55;
     monitor = "2560 x 1440";
     break;

  case 4: 
     performanceScore = ((5 * gpuSpeed) + (numCore * cpuSpeed)) * .35;
     monitor = "3840 x 2160";
     break;
}

if(performanceScore > 17000.0)
{
  performance = "Ultra";
}
else if(performanceScore > 15000.0 && performanceScore < 17000.0)
{
  performance = "High";
}
else if(performanceScore > 13000.0 && performanceScore < 15000.0)
{
  performance = "Medium";
}
else if(performanceScore > 11000.0 && performanceScore < 13000.0)
{
  performance = "Low";
}
else if(performanceScore == 11000.0 || performanceScore < 11000.0)
{
  performance = "Unable to Play";
}
System.out.println("Recommended Graphics Quality: " + performance);

Aucun commentaire:

Enregistrer un commentaire