This is the Pseudo Code : //Chapter 7: Programming Exercise 14 Pseudo Code and L
ID: 3532978 • Letter: T
Question
This is the Pseudo Code:
//Chapter 7: Programming Exercise 14 Pseudo Code and Logic
import java.io.and java.util packages
Create public class Ch7_PrExercise14
Setup public static void main(String[] args) with throws FileNotFoundException
//variable declarations
integer counter
DoubleClass courseAvg = new DoubleClass()
double classAvg
String name
char grade
Setup inFile as new Scanner as new FileReader with file name Ch7_Ex14Data.txt
Setup outFile = new PrintWriter with file name of Ch7_Ex14out.txt
output headings "Student Test1 Test2 Test3 Test4 Test5 Average Grade" to outfile
Get input in a While loop(inFile.hasNext)
Get name from inFile.next();
Output name to outFile.printf("%-10s", name);
Call CalculateAverage passing (inFile, outFile, courseAvg)
Output outFile.printf("%6.2f ", courseAvg.getNum());
Calculate classAvg = classAvg + courseAvg.getNum()
Calculate grade = call calculateGrade(courseAvg.getNum());
Output grade outFile.printf("%3s%n", grade);
End Loop
Calculate classAvg = classAvg / 10
Output Class Average to outFile
Close outFile
***Routine calculateAverage(Scanner inF, PrintWriter outF, DoubleClass CAvg)
{
Declare integers for score, sum and count
Setup Loop for 5 times for the five grades (for)
get score = inF.nextInt()
output score to outfile
add score to sum total
end loop
calculate the score average ( sum / 5.0)
***End Routine calculateAverage
***Routine calculateGrade(double avg)
if average >= 90
return grade of 'A'
else if average >= 80
return grade of 'B'
else if (average >= 70
return grade of 'C'
else if (average >= 60)
return grade of 'D'
else
return grade of 'F'
***End Routine calculateGrade
Explanation / Answer
chuck this in there: class DoubleClass{ DoubleClass(double a) { cont = a; } public void set(double a) { cont = a; } public void divide(double a) { cont = cont/a; } public double doubleValue() { return cont; } private double cont; }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.