问题描述
我的作业:
编写一个程序,它将执行以下任务.声明并初始化两个变量,这些变量代表两个测试中学生的分数.平均成绩应通过将测试分数相加并除以2来计算.然后,应根据平均成绩确定字母等级.应使用以下评分:A = 90-100,B = 80-89,C = 70-79,D = 65-69,F = 64以下.该程序应显示平均考试成绩和学生的字母成绩.
我的回答(您可以检查并修复):
my Assignment:
Write a program that will do the following tasks. Declare and initialize two variables that represent a student''s scores on two tests. The grade average should be computed by summing the test scores and dividing by 2. Then, a letter grade should be determined based on the average grade. The following scoring shall be used: A = 90-100, B = 80-89, C = 70-79, D = 65-69, F = 64 or less. The program should display the average test score and the student''s letter grade.
My answer (can you check and fix):
public class TestGrades
{
public static void main (String [] args)
{
int gradeone=75;
int gradetwo=80;
int testscore= ((gradeone + gradetwo)/2);
char grade;
System.out.println("\n" + "your test score is" + testscore);
if(testscore >= 90 )
grade='A';
elseif(testscore >= 80 );
grade='B';
elseif(testscore >= 70 );
grade='C';
elseif(testscore >= 65 );
grade='D';
else
grade='F';
}
}
推荐答案
if(testscore >= 90 )
grade='A';
else if((testscore >= 80 ) && (testscore < 90))
grade='B';
else if((testscore >= 70 ) && (testscore < 80))
grade='C';
else if((testscore >= 65 ) && (testscore < 70))
grade='D';
else
grade='F';
lewax00还会通知您一些语法错误.
there are also some syntax errors which is informed you earlier by lewax00..
这篇关于你能检查java答案吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!