Java 尝试从多个方法获取信息
我必须编写一个程序,要求用户提供5个测试分数,然后使用CalAverage和DeterminateGrade方法,我需要将平均分数和基于该分数的更高分数打印到屏幕上。我被困在determineGrade方法中我需要写的东西上,这就是我到目前为止所拥有的Java 尝试从多个方法获取信息,java,Java,我必须编写一个程序,要求用户提供5个测试分数,然后使用CalAverage和DeterminateGrade方法,我需要将平均分数和基于该分数的更高分数打印到屏幕上。我被困在determineGrade方法中我需要写的东西上,这就是我到目前为止所拥有的 package homework_chap5; import java.util.Scanner; public class Homework_Chap5 { //Pg 313 #7 public static vo
package homework_chap5;
import java.util.Scanner;
public class Homework_Chap5 {
//Pg 313 #7
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Enter first test score: ");
int s1 = s.nextInt();
System.out.print("Enter second test score: ");
int s2 = s.nextInt();
System.out.print("Enter third test score: ");
int s3 = s.nextInt();
System.out.print("Enter fourth test score: ");
int s4 = s.nextInt();
System.out.print("Enter fifth test score: ");
int s5 = s.nextInt();
System.out.println("Average is " + calcAverage(s1, s2, s3, s4, s5) +
"\nYour grade is a " + determineGrade());
}
public static float calcAverage(int s1, int s2, int s3, int s4, int s5){
float sum = s1 + s2 + s3 + s4 + s5;
float average = sum / 5;
return average;}
public static float determineGrade(int score) {
return grade;
}
}
下面的解决方案计算给定测试次数的平均分数。要计算等级,请执行以下操作: 从平均分数中找出百分比。例如,如果测试分数为50分,则最大分数变为50分,并将其转换为百分比。 获得百分比后,创建百分比到等级映射表。我的表格如下所示,您可以根据您的成绩要求进行更改: 百分比等级 90-100 A 80-90 B 60-80摄氏度 = 90.0{ 等级=‘A’; }否则,如果百分比>=80.0{ 等级=‘B’; }否则,如果百分比>=60.0{ 等级=‘C’; }否则{ 等级='D'; } 返回等级; } }
你想要什么分数,你的标准是什么?