提供多个数据值后,可以编写哪些代码来比较数据并确定最高/最低值?JAVA

提供多个数据值后,可以编写哪些代码来比较数据并确定最高/最低值?JAVA,java,Java,我在这个网站上寻找与查找程序中最高/最低数据值有关的答案,但我找到的只是与数组有关的代码。我的代码中没有数组,因此我假设查找最高值或最低值的技术将以不同的方式执行 如果您查看我的代码,您可以在输出的底部看到两行代码: The highest performance score was: 0 The lowest performance score was: 0 我只是不知道如何使用代码来输出最高性能分数或最低性能分数。我希望对两台计算机的两个性能分数进行分析、比较和显示,而不是那些0。同样,我

我在这个网站上寻找与查找程序中最高/最低数据值有关的答案,但我找到的只是与数组有关的代码。我的代码中没有数组,因此我假设查找最高值或最低值的技术将以不同的方式执行

如果您查看我的代码,您可以在输出的底部看到两行代码:

The highest performance score was: 0
The lowest performance score was: 0
我只是不知道如何使用代码来输出最高性能分数或最低性能分数。我希望对两台计算机的两个性能分数进行分析、比较和显示,而不是那些0。同样,我希望它不是输出中的0,而是:

The highest performance score was: 15400.000000000002
The lowest performance score was: 13000.0
那么我该如何执行这个呢?感谢所有的帮助

输出:

How many computers are being processed? 2

Computer Hardware Graphics Quality Recommendation Tool

Enter the clock speed (in Megahertz) of your graphics card: 1000
Enter the clock speed (in Megahertz) of your processor: 2000
Enter the number of cores that your processor has: 4
Monitor resolution menu:
1. 1280 x 720
2. 1920 x 1080
3. 2560 x 1440
4. 3840 x 2160
Please select one of the choices above: 1

GPU Clock Speed: 1000 MHz
CPU Clock Speed: 2000 MHz
Number of cores: 4
Monitor Resolution: 1280 x 720
Performance Score: 13000.0
Recommended Graphics Quality: Medium

The highest performance score was: 0
The lowest performance score was: 0

Computer Hardware Graphics Quality Recommendation Tool

Enter the clock speed (in Megahertz) of your graphics card: 2000
Enter the clock speed (in Megahertz) of your processor: 3000
Enter the number of cores that your processor has: 6
Monitor resolution menu:
1. 1280 x 720
2. 1920 x 1080
3. 2560 x 1440
4. 3840 x 2160
Please select one of the choices above: 3

GPU Clock Speed: 2000 MHz
CPU Clock Speed: 3000 MHz
Number of cores: 6
Monitor Resolution: 2560 x 1440
Performance Score: 15400.000000000002
Recommended Graphics Quality: High

The highest performance score was: 0
The lowest performance score was: 0
我的代码:

/*
This program will help the user identify and further understand the capabilities of their computer's hardware.
When the program is run, the user will be asked to input facts and information about their computer's hardware.
Once the information about the user's computer hardware is processed by the program,
the user will see results that explain the capabilities and potential of their computer.
In this new edition of the program, the user will have the option to analyze multiple computers, rather than just one.
They will also be able to compare their computer's performance score at the end.
*/

import java.util.Scanner; //This allows the program to utilize the Scanner class to get the user's input.


public class Project2_Ben_Mayo
{
   public static void main(String[] args)
   {


   String title = "Computer Hardware Graphics Quality Recommendation Tool"; //Title string
   int numOfComputers = 0; //To hold the number of computers being tested
   int GPUspeed = 0; //To hold the user's GPU clock speed (in Megahurtz)
   int CPUspeed = 0; //To hold the user's CPU clock speed (in Megahurtz)
   int numCores = 0; //To hold the number of cores in the user's CPU
   int menuChoice = 0; //To hold the user's menu choice
   String monitorRes = ""; //To hold the user's monitor resoltion
   String quality = ""; //To hold the quality of performance while gaming
   double multiplier = 0.0; //To hold the multiplier value
   double performanceScore = 0.0; //To hold the performance score value
   int highestScore = 0;
   int lowestScore = 0;

   Scanner sc = new Scanner(System.in); //This is the scanner object


   System.out.print("\n" + "How many computers are being processed? "); //ask the user to enter the number of computers they would like to test
   numOfComputers = sc.nextInt();

   if (numOfComputers <= 0) { //If the number of computers is less than or equal to 0, this notifies the user that the number of computers must be greater than or equal to 1
   System.out.print("The number of computers being processed must be at least one.");
   }


   //Use for loop to ask the user to enter the information for each computer
   for(int computerNumber = 0; computerNumber < numOfComputers; computerNumber++) { //Begin for loop

   System.out.println("\n" + title); //Print the title

   System.out.print("\n" + "Enter the clock speed (in Megahertz) of your graphics card: "); //This is an indicator of how fast the user's graphics card is
   GPUspeed = sc.nextInt();

   while(GPUspeed < 800 || GPUspeed > 2000) { //While the user provides an invalid input, display an error message and have them re-enter their input
      System.out.print("Invalid input. Plase enter a valid GPU speed: "); //display an error message if the user gave invalid input
      GPUspeed = sc.nextInt(); //re-read in the user's input for the GPU speed
   }


   System.out.print("Enter the clock speed (in Megahertz) of your processor: "); //This is an indicator of how fast the user's processor is
   CPUspeed = sc.nextInt();

    while(CPUspeed < 1000 || CPUspeed > 5500) { //While the user provides an invalid input, display an error message and have them re-enter their input
      System.out.print("Invalid input. Plase enter a valid CPU speed: "); //display an error message if the user gave invalid input
      CPUspeed = sc.nextInt(); //re-read in the user's input for the CPU speed
   }


   System.out.print("Enter the number of cores that your processor has: "); //This is an indicator of how many cores the user's CPU contains
   numCores = sc.nextInt();

    while(numCores < 1 || numCores > 16) { //While the user provides an invalid input, display an error message and have them re-enter their input
      System.out.print("Invalid input. Plase enter a valid number of cores: "); //display an error message if the user gave invalid input
      numCores = sc.nextInt(); //re-read in the user's input for the number of cores
   }



   //Monitor resolution menu
   System.out.println("Monitor resolution menu:");
   System.out.println("1. 1280 x 720");
   System.out.println("2. 1920 x 1080");
   System.out.println("3. 2560 x 1440");
   System.out.println("4. 3840 x 2160");

   System.out.print("Please select one of the choices above: "); //Ask the user to choose the resolution of their monitor
   menuChoice = sc.nextInt();

   while(menuChoice < 1 || menuChoice > 4) { //While the user provides an invalid input, display an error message and have them re-enter their input
      System.out.print("Invalid selection. Plase pick a valid option from the menu: "); //display an error message if the user gave invalid input
      menuChoice = sc.nextInt(); //re-read in the user's input for the menu selection
   }


   //Assign the menu options to their values to enable the menu to funtion correctly
   if (menuChoice == 1) {        //If the user selects menu option number 1, "monitorRes" = "1280 x 720"
      monitorRes = "1280 x 720";
   }
   else if (menuChoice == 2) {   //If the user selects menu option number 2, "monitorRes" = "1920 x 1080"
      monitorRes = "1920 x 1080";
   }
   else if (menuChoice == 3) {   //If the user selects menu option number 3, "monitorRes" = "2560 x 1440"
      monitorRes = "2560 x 1440";
   }
   else if (menuChoice == 4) {   //If the user selects menu option number 4, "monitorRes" = "3840 x 2160"
      monitorRes = "3840 x 2160";
   }


   //This segment will determine what the mulitplier object will be
   if (menuChoice == 1) {
      multiplier = 1;
   }
   else if (menuChoice == 2) {
      multiplier = .75;
   }
   else if (menuChoice == 3) {
      multiplier = .55;
   }
   else if (menuChoice == 4) {
      multiplier = .35;
   }


   //Performance Score multiplier
   performanceScore = ((5 * GPUspeed) + (numCores * CPUspeed)) * multiplier;



   //Recommended graphics quality that the user's hardware can support.
   if (performanceScore >= (17000)) {       //If the performance score is greater than or equal to 17,000, the quality of the performance is ultra
      quality = "Ultra";
   }
   else if (performanceScore >= (15000)) {  //If the performance score is greater than or equal to 15,000, the quality of the performance is high
      quality = "High";
   }
   else if (performanceScore >= (13000)) {  //If the performance score is greater than or equal to 13,000, the quality of the performance is medium
      quality = "Medium";
   }
   else if (performanceScore >= (11000)) {  //If the performance score is greater than or equal to 11,000, the quality of the performance is low
      quality = "Low";
   }
   else if (performanceScore < (11000)) {   //If the performance score is less than 11,000, the quality of the performance is unplayable
      quality = "Unable to Play";
   }


   //Print the results
   System.out.println("\nGPU Clock Speed: " + GPUspeed + " MHz"); //User's GPU speed (in Megahurtz)
   System.out.println("CPU Clock Speed: " + CPUspeed + " MHz"); //User's CPU speed (in Megahurtz)
   System.out.println("Number of cores: " + numCores); //Number of cores that the user's CPU contains
   System.out.println("Monitor Resolution: " + monitorRes); //User's moniter resolution
   System.out.println("Performance Score: " + performanceScore); //The user's computer performance score
   System.out.println("Recommended Graphics Quality: " + quality); //Estimated quality of graphics during gameplay

   System.out.println("\n" + "The highest performance score was: " + highestScore);
   System.out.println("The lowest performance score was: " + lowestScore);

      } //End for loop
   } //End class
} //End main
/*
此程序将帮助用户识别并进一步了解其计算机硬件的功能。
当程序运行时,将要求用户输入有关其计算机硬件的事实和信息。
一旦程序处理了有关用户计算机硬件的信息,
用户将看到解释其计算机功能和潜力的结果。
在新版程序中,用户可以选择分析多台计算机,而不是一台计算机。
最后,他们还可以比较电脑的性能分数。
*/
导入java.util.Scanner//这允许程序利用Scanner类获取用户的输入。
公共类项目2_Ben_Mayo
{
公共静态void main(字符串[]args)
{
String title=“计算机硬件图形质量推荐工具”;//标题字符串
int numOfComputers=0;//保存正在测试的计算机数量
int GPUspeed=0;//用于保持用户的GPU时钟速度(以兆赫兹为单位)
int CPUspeed=0;//保持用户的CPU时钟速度(以兆赫为单位)
int numCores=0;//保存用户CPU中的内核数
int menuChoice=0;//保存用户的菜单选项
字符串monitorRes=“;//用于保存用户的监视器解析
String quality=“;//在玩游戏时保持性能质量
double乘数=0.0;//保存乘数值
double performanceScore=0.0;//保存性能分数值
int最高分=0;
int最低分数=0;
Scanner sc=new Scanner(System.in);//这是Scanner对象
System.out.print(“\n”+“正在处理多少台计算机?”);//请用户输入他们要测试的计算机数量
numOfComputers=sc.nextInt();
如果(numOfComputers 4){//而用户提供的输入无效,则显示错误消息并让他们重新输入输入
System.out.print(“无效选择。请从菜单中选择有效选项:”;//如果用户输入无效,则显示错误消息
menuChoice=sc.nextInt();//重新读取用户对菜单选择的输入
}
//将菜单选项指定给它们的值,以使菜单正确运行
如果(menuChoice==1){//如果用户选择了菜单选项1,“监视器”=“1280 x 720”
monitorRes=“1280 x 720”;
}
否则如果(menuChoice==2){//如果用户选择菜单选项2,“监视器”=“1920 x 1080”
monitorRes=“1920 x 1080”;
}
否则,如果(menuChoice==3){//如果用户选择菜单选项3,“监视器”=“2560 x 1440”
monitorRes=“2560 x 1440”;
}
else如果(menuChoice==4){//如果用户选择菜单选项4,“监视器”=“3840 x 2160”
monitorRes=“3840 x 2160”;
}
//此段将确定mulitplier对象是什么
如果(menuChoice==1){
乘数=1;
}
else if(menuChoice==2){
乘数=.75;
}
else if(menuChoice==3){
乘数=.55;
}
else if(menuChoice==4){
乘数=.35;
}
//绩效分数乘数
性能核心=((5*GPUspeed)+(numCores*CPUspeed))*乘数;
//用户硬件可以支持的推荐图形质量。
如果(PerformanceCore>=(17000)){//如果绩效分数大于或等于17000,则绩效质量超高
质量=“超”;
}
否则,如果(PerformanceCore>=(15000)){//如果性能分数大于或等于15000,则性能质量较高
质量=“高”;
}
否则,如果(PerformanceCore>=(13000)){//如果绩效分数大于或等于13000,则绩效质量为中等
质量=“中等”;
}
否则,如果(PerformanceCore>=(11000)){//如果性能分数大于或等于11000,则性能质量较低
质量=“低”;
}
否则,如果(PerformanceCore<(11000)){//如果性能分数低于11000,则性能质量不可播放
quality=“无法播放”;
}
//打印结果
System.out.println(“\nGPU时钟速度:“+GPUspeed+”MHz”);//用户的GPU速度(以兆赫兹为单位)
System.out.println(“CPU时钟速度:+CPUspeed+“MHz”);//用户的CPU速度(以兆赫兹为单位)
System.out.println(“内核数:+numCores);//用户CPU包含的内核数
System.out.println(“监视器分辨率:”+monitorRes);//用户的监视器分辨率
System.out.println(“性能分数:+performanceScore);//用户的计算机性能分数
System.out.println(“推荐的图形质量:+质量);//游戏期间估计的图形质量
System.out.println(“\n”+”最高性能分数为:“+最高分数”);
System.out.println(“最低性能分数为:“+最低分数”);
}//循环结束
}//结束
if(performanceScore > highestScore) {
    highestScore = performanceScore;
}
if(lowestScore == 0 || performanceScore < lowestScore) {
    lowestScore = performanceScore;
}