Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //LIM FANG HAO 1161203916
- //D7
- //LAB 3A
- import java.util.Scanner;
- public class Q1 {
- public static void main(String [] args){
- Scanner input=new Scanner(System.in);
- System.out.print("Enter score for quiz 1: ");
- int score1=input.nextInt();
- System.out.print("Enter score for quiz 2: ");
- int score2=input.nextInt();
- System.out.print("Enter score for quiz 3: ");
- int score3=input.nextInt();
- int total=getTotal(score1,score2,score3);
- double avg=getAverage(total);
- printAll(avg,total);
- }
- public static int getTotal(int score1,int score2,int score3){
- int total=score1+score2+score3;
- return total;
- }
- public static double getAverage(int total){
- double avg=(double)total/3;
- return avg;
- }
- public static void printAll(double avg,int total){
- System.out.println("The total score of quizzes is = "+total);
- System.out.printf("The average of score is = %.2f\n",avg);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement