Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class ComputeGrade5
- {
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- System.out.print("How many homework assignments are there?");
- String input = scan.next();
- int total = Integer.parseInt(input);
- //System.out.print("There are " + total+ " homework assignments");
- double average=0;
- for(int i = 1; i <= total; i++)
- {
- System.out.print("What was the grade for Assignment " + i + "?");
- average = average + scan.nextDouble();
- }
- average = average/total;
- DecimalFormat newThing = new DecimalFormat("#,###,###0.00");
- double thing = average;
- System.out.println("\nYour average assignment is " + newThing.format(thing));
- System.out.print("\nWhat is your midterm exam score?");
- String midterm = scan.next();
- System.out.print("What is your final exam score");
- String finalExam = scan.next();
- int midtermScore = Integer.parseInt(midterm);
- int finalExamScore = Integer.parseInt(finalExam);
- double TotalAverage;
- TotalAverage = (average*total + midtermScore + finalExamScore) / (total + 2);
- DecimalFormat someThing = new DecimalFormat("#,###0.00");
- System.out.print("\nYour average for the class is a " + someThing.format(TotalAverage));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement