Advertisement
Guest User

lab3aq1

a guest
Dec 11th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. //LIM FANG HAO 1161203916
  2. //D7
  3. //LAB 3A
  4. import java.util.Scanner;
  5. public class Q1 {
  6. public static void main(String [] args){
  7. Scanner input=new Scanner(System.in);
  8. System.out.print("Enter score for quiz 1: ");
  9. int score1=input.nextInt();
  10. System.out.print("Enter score for quiz 2: ");
  11. int score2=input.nextInt();
  12. System.out.print("Enter score for quiz 3: ");
  13. int score3=input.nextInt();
  14.  
  15. int total=getTotal(score1,score2,score3);
  16. double avg=getAverage(total);
  17. printAll(avg,total);
  18. }
  19. public static int getTotal(int score1,int score2,int score3){
  20. int total=score1+score2+score3;
  21. return total;
  22. }
  23.  
  24. public static double getAverage(int total){
  25. double avg=(double)total/3;
  26. return avg;
  27. }
  28.  
  29. public static void printAll(double avg,int total){
  30. System.out.println("The total score of quizzes is = "+total);
  31. System.out.printf("The average of score is = %.2f\n",avg);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement