1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
bixtya [17]
3 years ago
15

7. Test Average and Grade Write a program that asks the user to enter five test scores. The program should display a letter grad

e for each score and the average test score. Write the following methods in the program: calcAverage: This method should accept five test scores as arguments and return the average of the scores. determineGrade: This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale: Score Letter Grade 90-100 A 80-89 B 70-79 C 60-69 D Below 60 F
Computers and Technology
1 answer:
Alenkasestr [34]3 years ago
5 0

Answer:

The code solution is written in Java.

  1. import java.util.Scanner;
  2. public class TestScore {
  3.    public static void main(String[] args) {
  4.        Scanner input = new Scanner(System.in);
  5.        System.out.print("Please enter first score: ");
  6.        double firstScore = input.nextDouble();
  7.        System.out.println("Grade: " + determineGrade(firstScore));
  8.        System.out.print("Please enter second score: ");
  9.        double secondScore = input.nextDouble();
  10.        System.out.println("Grade: " + determineGrade(secondScore));
  11.        System.out.print("Please enter third score: ");
  12.        double thirdScore = input.nextDouble();
  13.        System.out.println("Grade: " + determineGrade(thirdScore));
  14.        System.out.print("Please enter fourth score: ");
  15.        double fourthScore = input.nextDouble();
  16.        System.out.println("Grade: " + determineGrade(fourthScore));
  17.        System.out.print("Please enter fifth score: ");
  18.        double fifthScore = input.nextDouble();
  19.        System.out.println("Grade: " + determineGrade(fifthScore));
  20.        System.out.println("Average score: " + calcAverage(firstScore, secondScore, thirdScore, fourthScore, fifthScore));
  21.    }
  22.    public static double calcAverage(double score1, double score2, double score3, double score4, double score5){
  23.        double average = (score1 + score2 + score3 + score4 + score5) / 5;
  24.        return average;
  25.    }
  26.    public static String determineGrade(double score){
  27.        if(score >= 90){
  28.            return "A";
  29.        }
  30.        else if(score >= 80 ){
  31.            return "B";
  32.        }
  33.        else if(score >=70){
  34.            return "C";
  35.        }
  36.        else if(score >=60){
  37.            return "D";
  38.        }
  39.        else{
  40.            return "F";
  41.        }
  42.    }
  43. }

Explanation:

Firstly, create the method, <em>calcAverage()</em>, that takes five test scores. Within the method, calculate the average and return it as output. (Line 33 - 36)

Next, create another method, <em>determineGrade()</em>, which takes only one score and return the grade based on the range of the  score. (Line 38 -54)

Once the two required methods are created, we are ready to prompt use for input five test scores using Java Scanner class. To use get user input, create a Scanner object (Line 7). Next, use getDouble() method to get an input score and assign it to variables firstScore, secondScore, thirdScore, fourthScore & fifthScore, respectively. Once a score input by user, call determineGrade() method by passing the input score as argument and immediately print out the return grade. (Line  9 - 27)

At last, call calcAverage() method by passing the first test score variables as argument and print out the returned average value. (Line 29).

You might be interested in
Stuck on where to go with this one.
garri49 [273]

1

7

6 I think how many do you have to answer

8 0
3 years ago
What was Leonardo da Vinci an expert in
Ipatiy [6.2K]

Leonardo da Vinci was a very famous painter. I would assume that he is an expert in painting.

Hope this helped

5 0
4 years ago
Please help me i need rn please help​
boyakko [2]

Answer: uty ute reb

Explanation:

3 0
2 years ago
Discuss, in brief thedifferent variations of BLAST. (Maximum 5 innumber)
schepotkina [342]

Answer:

Five variations od BLAST are as following:-

  1. BLASTP
  2. BLASTX
  3. TBLASTX
  4. BLASTN
  5. TBLASTN

Explanation:

BLASTP - Searches a protein database with a protein sequence.

BLASTX - This program searches protein database using a translated nucleotide sequence.

TBLASTX - Searches DNA databases using a protein query.

BLASTN -Searches a nucleotide sequence against DNA database.

TBLASTN - Searches nucleotide sequence to a DNA database.

5 0
4 years ago
A small bank with several regional branches is searching for a solution to consolidate its business services into a single site
Licemer1 [7]

Answer:

private cloud

Explanation:

Based on the scenario being described it can be said that the best method to meet the banks needs would be implementing a private cloud. This is an pool of shared computing resources in a public cloud, but one which is completely isolated from other organizations using the same provider or cloud resources. Which is exactly what the small bank needs in this situation.

4 0
3 years ago
Read 2 more answers
Other questions:
  • The integer variables first and last have been declared and assigned values (with last &gt;= first). Allocate an integer array t
    10·1 answer
  • what is the goal of technology A. to understand how the natural world functions B. to study the natural world C. to improve the
    9·1 answer
  • What is the most likely result of a correctly installed processor, but an incorrectly installed cooler?
    6·1 answer
  • Which of the following protects intellectual property?copyright
    9·2 answers
  • Discuss at least two challenges students face when conducting research on the Internet.
    7·2 answers
  • What does "scanf(\"%d\" mean?
    13·2 answers
  • What was your favorite animals, game, photo, friends,
    7·2 answers
  • The sequence of instructions performed to execute one program instruction
    12·1 answer
  • Consider legal issues and intellectual property concerns when creating computer programs?
    11·1 answer
  • The agency that started ARPANET was looking for
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!