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
snow_lady [41]
3 years ago
6

Write a program that prompts the user to enter five test scores and then prints the average test score. Indicate the average tes

t score by printing it to the terminal.

Computers and Technology
1 answer:
eduard3 years ago
5 0

Answer:

I am writing the program in C++ and Python.

C++ code:

#include <iostream>  // for input output functions

using namespace std;   // identifies objects like cin cout

int main() //start of main() function body

{  //  test scores variables are declared along with average and sum variables

 double test_score1, test_score2, test_score3, test_score4, test_score5, average, sum;      

   cout << "Enter 5 test scores: \n";  //prompts user to enter 5 test scores

   cin >> test_score1 >> test_score2 >> test_score3 >> test_score4 >> test_score5;  //reads values of five test scores entered by user

   sum = test_score1 + test_score2 + test_score3 + test_score4 + test_score5;  // calculates the sum of the five test scores

   average = sum / 5;      //computes the average of five test scores

   cout << "The average test score is: " << average;  

 //displays the computer average of the five test scores entered by the user

}

Explanation:

The program prompts the user to enter the values of 5 test scores. It the calculates the sum of all these 5 input test scores and stores the result in sum variable. In order to compute average test score the sum of these 5 test scores is divided by the total number of test scores that is 5 and the result is stored in average variable. Lastly it displays the average by displaying the value of the average stored in the average variable.

Python Program:

num=5  # total number of test scores

list=[]  #list to store values of 5 test scores

for i in range(0,num):  #loop to enter values of test scores

#prompts user to enter values for 5 test scores

   test_scores =int(input("Enter the five test scores"))

   list.append(test_scores)  #appends the input test scores in the list

average=sum(list)/num  #calculates sum of the values stored in list and #divides the value of sum with the total number of test scores i.e. 5

print("Average test score is: ",round(average,2))

#displays average of the five test scores rounding up to two decimal places

Explanation:

This is a small program in Python to compute average test score. If you want to take separate input for each of the five test scores you can use the following program:

#takes value for each test score seperately from user

testScore1 = int(input('Enter 1st test score: '))  

testScore2 = int(input('Enter 2nd test score : '))

testScore3 = int(input('Enter 3rd test score : '))

testScore4 = int(input('Enter 4th test score : '))

testScore5 = int(input('Enter 5th test score : '))  

#calculates sum of each test score

sum = (testScore1 + testScore2 + testScore3 + testScore4 + testScore5)  

#method to compute average test score

def average(sum):

   return sum / 5         #divide value of sum with total number of test scores  

#calls average function to display average test score using print statement

print("average test score is: " , average(sum))

The programs along with their outputs is attached in the screenshots.

You might be interested in
Describe what skills are required by the helpdesk technician for each step in a typical incident process.
Shalnov [3]
They need to be organized
<span>Critical Thinking. Oftentimes, help desk technicians have flow charts or predefined procedures they can follow to resolve known problems. ...Written Communication. ...Active Listening. ...Verbal Communication. ...<span>Conflict Resolution. all these are good. Sorry about how long you had to wait and i hope this helps.</span></span>
6 0
3 years ago
Which of the following is a sample IPv4 address?
const2013 [10]

Answer:

The first one, 99.14.242.51 is the only valid IPv4 address listed.

Explanation:

An IPv4 address is formatted as four eight-bit numbers separated by decimals. This means that a valid one will have four numbers from 0 to 255, with decimals in between.

The first one, 99.14.242.51 is a valid IPv4 address.

The second one has the number 342, which is greater than eight bits.

The third one has five octets.

The fourth one is in the wrong format altogether, using what appear to be 32-bit numbers

7 0
3 years ago
Write an if statement to test if a number stored in y is between 6 and 10 inclusive.
lana66690 [7]

y = choose whatever number you want.

if 5 < y < 11:

   print("The value stored in y is between 6 and 10 inclusive")

else:

   print("The value stored in y is not between 6 and 10 inclusive.")

I hope this helps!

8 0
3 years ago
Using technologies increase the time needed to complete a task is beneficial
nata0808 [166]

Answer:

True

Explanation:

The advent of technology has given human to achieve a whole lot more in a rather short period of time when compared to the period where the major tool of engagement and task is Manual. With technology, aside from having the ability to complete task faster, we can achieve more accurate result and a lot attractive output. All these in very little time. Technology has helped industries grow multiple times faster thus increasing input, yield and productivity. The tedious nature of having to work manually has also been expunged with repetitive task now being programmed and automated.

3 0
3 years ago
Write a program that creates a map containing the U.S. states as keys, and their capitals as values. (Use the Internet to get a
seraphim [82]

Answer:

Here is the Python program:

import random  #  to generate random numbers

def quiz():  #method quiz to ask state's capital

   capitals={"Washington":"Olympia","Oregon":"Salem",\

                   "California":"Sacramento","Ohio":"Columbus",\

                   "Nebraska":"Lincoln","Colorado":"Denver",\

                   "Michigan":"Lansing","Massachusetts":"Boston",\

                   "Florida":"Tallahassee","Texas":"Austin",\

                   "Oklahoma":"Oklahoma City","Hawaii":"Honolulu",\

                   "Alaska":"Juneau","Utah":"Salt Lake City",\

                   "New Mexico":"Santa Fe","North Dakota":"Bismarck",\

                   "South Dakota":"Pierre","West Virginia":"Charleston",\

                   "Virginia":"Richmond","New Jersey":"Trenton",\

                   "Minnesota":"Saint Paul","Illinois":"Springfield",\

                   "Indiana":"Indianapolis","Kentucky":"Frankfort",\

                   "Tennessee":"Nashville","Georgia":"Atlanta",\

                   "Alabama":"Montgomery","Mississippi":"Jackson",\

                   "North Carolina":"Raleigh","South Carolina":"Columbia",\

                   "Maine":"Augusta","Vermont":"Montpelier",\

                   "New Hampshire":"Concord","Connecticut":"Hartford",\

                   "Rhode Island":"Providence","Wyoming":"Cheyenne",\

                   "Montana":"Helena","Kansas":"Topeka",\

                   "Iowa":"Des Moines","Pennsylvania":"Harrisburg",\

                   "Maryland":"Annapolis","Missouri":"Jefferson City",\

                   "Arizona":"Phoenix","Nevada":"Carson City",\

                   "New York":"Albany","Wisconsin":"Madison",\

                   "Delaware":"Dover","Idaho":"Boise",\

                   "Arkansas":"Little Rock","Louisiana":"Baton Rouge"}

#dictionary of states along with their capitals    

   quit=False   #exit option

   print ("Welcome to the States capitals quiz game!")  

   wrong_ans = False   # boolean variable for incorrect answer

   while not quit and len(capitals)>0:  

#loop continues until all state capitals are finished and user presses q

       choice = random.choice(list(capitals.keys()))  

#choice variable stores randomly generated list of pick

       right_ans = capitals.get(choice)  #stores correct answer

       print ("\nWhat is the capital city of",choice,"?")

       user_ans = input("Your guess:  ")  #answer entered by user

       if user_ans.lower()=='q':  #if user presses q to quit

           quit=True  #quit value become true

           print("The quiz is over! Bubye!")  

#displays the above message and quits the program

       elif user_ans.lower()==right_ans.lower():  #if user enters correct guess

           print ("Right Answer! \n")  # displays this message

       else:  #if user enters wrong guess

           print ("Wrong Answer!\n")  #displays wrong answer message

           print ("The right answer is ",right_ans)  #prints right capital

           wrong_ans = True          

quiz()       #calls quiz function to begin with the quiz

Explanation:

The program has a dictionary that contains the US states as keys and their capitals as values. The program asks the user to enter the capital of a random state. This state is selected randomly from the list of states using random function and keys() method is used to display list of all keys in the capital states dictionary. The while loop starts which keeps asking the user to guess the capital of states. This loop ends when the user types q to quit the program or all the capitals of the states are covered. Now the user guess is compared to the right answer, if the user has correctly guessed the capital then the Right answer message is displayed otherwise Wrong answer is displayed. After Wrong answer message the correct answer  is displayed and the quiz starts again until the user enters q to exit. When the user types q the message: The quiz is over! Bubye! is displayed and the programs exits.

8 0
4 years ago
Other questions:
  • Write a function called ReverseLetters that takes an input phrase consisting of a single word and reverses the sequence of lette
    15·1 answer
  • What 2 major agricultural inventions did jethro tull create?
    10·2 answers
  • A weak fuel to air mixture along with normal airflow through a turbine engine may result in?
    8·1 answer
  • An example of software most commonly associated with productivity software is ____.
    12·1 answer
  • The ability to keep web page visitors at your site is called _______.
    11·1 answer
  • What is the output of the below Java program?
    11·1 answer
  • PLZZZZZ help will give brainleist <br> Two common sound files are?
    11·1 answer
  • Activity 8. Direction: Read the article and make an outline. Be guided by the rubric for outlining. Write your answer on a separ
    15·1 answer
  • Not all output display data for humans to read explain why​
    13·1 answer
  • Pick the 3 correct Python functions that parse and output only the date and time part of each log in log.txt as follows.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!