Question
double totalscore = 0,avg; int score,count = 0; String grade; while(inF.hasNextInt()) { score= inF.nextInt(); if(vaildScore(score)) { grade = letterGrade(score); System.out.printf(%d %s %n,score,grade); totalscore += score;
double totalscore = 0,avg; int score,count = 0; String grade; while(inF.hasNextInt()) {
score= inF.nextInt(); if(vaildScore(score)) { grade = letterGrade(score); System.out.printf("%d %s %n",score,grade); totalscore += score; count++; }
else { System.out.printf("%d Invaild score%n",score); } } inF.close(); avg= totalscore/ count; System.out.printf("Average: %.2f, Letter Grade: %s %n",avg , letterGrade(avg)); System.out.printf("%nEnd of Program%n");
}
static boolean vaildScore(double score) { if (score 100) return false;
else return true; }
static String letterGrade(double score) { if(score >= 90) return "A"; else if(score >= 80) return "B"; else if(score >= 70) return "C"; else if(score >= 60) return "D"; else return "F"; } }
Note: there are 58 Sample Output and - in the header. **Lab 10 Fall 2018
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started