Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Scanner;
  3. public class ComputeGrade5
  4. {
  5. public static void main(String[] args)
  6. {
  7. Scanner scan = new Scanner(System.in);
  8. System.out.print("How many homework assignments are there?");
  9. String input = scan.next();
  10. int total = Integer.parseInt(input);
  11. //System.out.print("There are " + total+ " homework assignments");
  12. double average=0;
  13. for(int i = 1; i <= total; i++)
  14. {
  15. System.out.print("What was the grade for Assignment " + i + "?");
  16. average = average + scan.nextDouble();
  17. }
  18.  
  19. average = average/total;
  20.  
  21. DecimalFormat newThing = new DecimalFormat("#,###,###0.00");
  22. double thing = average;
  23. System.out.println("\nYour average assignment is " + newThing.format(thing));
  24.  
  25. System.out.print("\nWhat is your midterm exam score?");
  26. String midterm = scan.next();
  27.  
  28. System.out.print("What is your final exam score");
  29. String finalExam = scan.next();
  30.  
  31. int midtermScore = Integer.parseInt(midterm);
  32. int finalExamScore = Integer.parseInt(finalExam);
  33.  
  34. double TotalAverage;
  35. TotalAverage = (average*total + midtermScore + finalExamScore) / (total + 2);
  36.  
  37. DecimalFormat someThing = new DecimalFormat("#,###0.00");
  38. System.out.print("\nYour average for the class is a " + someThing.format(TotalAverage));
  39.  
  40.  
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement