answer.
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]
2 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]2 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
A semaphore puts a thread to sleep:
otez555 [7]

Answer:

B. until another thread issues a notify on the semaphore.

Explanation:

A semaphore is a variable that is shared between threads and is not negative. It also acts as a calling mechanism that uses two atomic operations wait and signal for synchronization of processes.

A thread that is waiting for a process can be signaled by another thread.

A semaphore puts a thread to sleep until another thread issues a notify on the semaphore.

The wait operation will get a semaphore or otherwise wait if the busy S semaphore is available.

The signal operation will release a semaphore or wake a process if there is a thread waiting for S.

3 0
2 years ago
3.A customer has a system with a Gigabyte B450 Aorus Pro motherboard. He wants to upgrade the processor from the AMD Athlon X4 9
Burka [1]

Answer:

The upgrade is possible and it will yield a remarkable  increase in performance

Explanation:

It is a newer product, there is tendency of having a better application compatibility/performance

It has much higher multi threaded performance which is around 522% higher. This allows for higher performance in professional applications like encoding and heavy multitasking compared to the previous.

When considering gaming, it has higher performance compared to the previous.

5 0
2 years ago
A 'array palindrome' is an array which, when its elements are reversed, remains the same (i.e., the elements of the array are sa
muminat

The code below is used to determine a recursive, bool-valued function, isPalindrome, that accepts an integer-valued array, and the number of elements and returns whether the array is a palindrome.

Explanation:

  • The code shows 'array palindrome' is an array which, when its elements are reversed, remains the same.

bool isPalindrome(arr[((n-1) - n) +1], n)

{

   if (n == 0 || n == 1)

   {

       return true;

   }

   else if (arr[n-1] == isPalindrome(arr[], n-1)

   {

       return true;

   }  

   else {

       return false;

   }

}

5 0
2 years ago
5.11 Of these two types of programs:a. I/O-boundb. CPU-boundwhich is more likely to have voluntary context switches, and which i
Leno4ka [110]

Answer:

The answer is "both voluntary and non-voluntary context switch".

Explanation:

The description to this question can be described as follows:

Whenever processing requires resource for participant contextual switch, it is used if it is more in the situation of I/O tied. In which semi-voluntary background change can be used when time slice ends or even when processes of greater priority enter.

  • In option a, It requires voluntary context switches in I /O bound.
  • In option b, it requires a non-voluntary context switch for CPU bound.
7 0
2 years ago
Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
qaws [65]

Answer:

Se explaination

Explanation:

/Declaring variables

integer currentPrice

integer lastMonthPrice

integer changeLastMonth

float mortagage

//Reading input

currentPrice = Get next input

lastMonthPrice = Get next input

//Calculating price change

changeLastMonth = currentPrice - lastMonthPrice

//Calculating mortagage

mortagage = (currentPrice * 0.051) / 12

//Printing output

Put "This house is $" to output

Put currentPrice to output

Put "\nThe change is $" to output

Put changeLastMonth to output

Put " since last month." to output

Put "\nThe estimated monthly mortgage is $" to output

Put mortagage to output

3 0
2 years ago
Other questions:
  • Name and summarize the four levels of administration necessary to keep human services organization operating smoothly
    9·2 answers
  • What type of hardware enables users to interact with a computer? Check all that apply. the CPU the hard disk drive the keyboard
    9·2 answers
  • FOREACH, EXPLODE and MAIL are examples of crazy functions.
    13·1 answer
  • The OSI security architecture provides a systematic framework for defining security attacks, mechanisms, and services. True or F
    12·1 answer
  • Write the definition of a class Telephone. The class has no constructors,
    8·2 answers
  • Liz's meeting is scheduled to end at 9:30. It is 9:20 and team
    11·1 answer
  • Assume each student is assigned an advisor from a department. Each classroom is assigned a classroom (class# determines Classroo
    14·1 answer
  • Why is accessing a disk block expensive? discuss the time components involved in accessing a disk block. (?
    9·1 answer
  • Do Exercise 6.4 from your textbook using recursion and the is_divisible function from Section 6.4. Your program may assume that
    6·1 answer
  • A credit card company receives numerous phone calls throughout the day from customers reporting fraud and billing disputes. Most
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!