Ask Question
8 July, 04:14

Create a program that contains 4 methods / functions ... main (), getTestScores (), calcAverage (), and displayAverage (). The main () method should call the getTestScores () method to get and return each of 3 test scores. The main function should then call the calcAverage () method and send the three scores down to calculate and return the average of the three test scores. The main () method should then call the displayAverage () method to display the average of test scores.

+3
Answers (1)
  1. 8 July, 07:05
    0
    import java. util. Scanner;

    public class num6{

    static int getTestScores () {

    System. out. println ("Enter the Score");

    Scanner in = new Scanner (System. in);

    int score = in. nextInt ();

    return score;

    }

    static double calcAverage (int score1, int score2, int score3) {

    return (score1+score2+score3) / 3;

    }

    static void displayAverage (double ave) {

    System. out. println ("The Average is "+ave);

    }

    public static void main (String[] args) {

    int num1 = getTestScores ();

    int num2 = getTestScores ();

    int num3 = getTestScores ();

    //Calling Calculate Average

    double average = calcAverage (num1, num2, num3);

    //Calling displayAverage

    displayAverage (average);

    }

    }

    Explanation:

    Using Java programming Language Create the four methods getTestScores () Uses the Scanner Class to receive an in variable and return it calcAverage () accepts three ints as parameter calculates their average and return it displayAverage () Accepts a double and prints it out with a concatenated string as message In the Main Method, getTestScores is called three times to obtain three numbers from the user calAverage is called and handed the three numbers printAverage is called to output the calculated average
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Create a program that contains 4 methods / functions ... main (), getTestScores (), calcAverage (), and displayAverage (). The main () ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers