194k views
2 votes
Write a program that has variables to hold three test scores. The program should ask the user to enter three test scores, and then assign the values entered to the variables.

2 Answers

5 votes

Final answer:

Create a program that prompts the user to input three test scores and saves those values in variables. An example in the Python language is given to demonstrate this.

Step-by-step explanation:

To write a program that handles test scores, we'll need to create variables to store the scores, prompt the user for input, and then save those inputs into the variables. Below is an example of how this could be done in a common programming language like Python:

# Prompt the user for test scores
test_score1 = float(input('Enter the first test score: '))
test_score2 = float(input('Enter the second test score: '))
test_score3 = float(input('Enter the third test score: '))

# Now, the variables test_score1, test_score2, and test_score3 hold the scores
print(f'Test scores entered: {test_score1}, {test_score2}, {test_score3}')

In this program, the input() function is used to get user input, which is then converted to a float (in case scores include decimals) and stored in the variables test_score1, test_score2, and test_score3.

User NiceToMytyuk
by
4.8k points
3 votes

The solution program has been coded in C language. It can be different for any other programming language

Step-by-step explanation:

#include <iostream>

using namespace std;

int main()

{

int score1,score2,score3;

cout<<"Enter Test score 1\\";

cin>>score1;

cout<<"Enter Test score 2\\";

cin>>score2;

cout<<"Enter Test score 3\\";

cin>>score3;

cout<<"Test Score 1 : "<<score1<<"\\";

cout<<"Test Score 2 : "<<score2<<"\\";

cout<<"Test Score 3 : "<<score3<<"\\";

return 0;

}

User Rohitpaniker
by
4.2k points