Question

In: Computer Science

c++ class Topics Branches if statement if/else statement Description Write a program that will determine whether...

c++ class

Topics

Branches

if statement

if/else statement

Description

Write a program that will determine whether the user passed or failed a test. The program will ask the user to input the following:

Maximum Test Score - the maximum total scores in the test.

Percent Pass Score - the minimum percent scores required to pass the test.

User Test Score - the actual scores obtained by the user in the test.

From the above input values, the program will compute the user percent score. It will compare the percent user score with the percent pass score. If the percent user score is equal to or greater than the percent pass score, the program will consider the user having passed the test. Otherwise, the program will consider the user having failed the test. At the end, the program will display the result summary. See the Test section below.

Testing

Perform the test run 1 and the test run 2 below with the data shown below.

(User input is shown in bold.)

(It's OK if your decimal values don't look the same as below so long as they are equal)

Test Run 1

Enter Maximum Test Score:

400

Enter Percent Pass Score:      

80

Enter User Test Score:

324

Result Summary

Test Result: Pass

User Test Score: 324

User Percent Score: 81.0 %

Maximum Score: 400

Percent Pass Score: 80.0 %

Test Run 2

Enter Maximum Test Score:

400

Enter Percent Pass Score:      

80

Enter User Test Score:

316

  

Result Summary

Test Result: Fail

User Test Score: 316

User Percent Score: 79.0 %

Maximum Score: 400

Percent Pass Score: 80.0 %

Submit

Copy the following in a file and submit that file.

Output of test runs.

All the C/C++ source code.

Sample Code

// declare variables

double maxScore, pctPassScore, userScore, pctUserScore;

//write code to input maxScore, pctPassScore, userScore

//determine pctUserScore

pctUserScore = (userScore / maxScore) * 100.0

//determine test result

cout << "Result Summary" << endl << endl;

if (pctUserScore >= pctPassScore) {

    cout << "Test Result: Pass" << endl;

}

else {

    cout << "Test Result: Fail" << endl;

}

Solutions

Expert Solution

#include <iostream>

using namespace std;

int main() {

// declare variables

double maxScore, pctPassScore, userScore, pctUserScore;

//write code to input maxScore, pctPassScore, userScore

//determine pctUserScore


cout<<"Enter Maximum Test Score:"<<endl;

cin>>maxScore;

cout<<"Enter Percent Pass Score:"<<endl;

cin>>pctPassScore;


cout<<"Enter User Test Score:"<<endl;

cin>>userScore;


pctUserScore = (userScore / maxScore) * 100.0;

//determine test result

cout << "Result Summary" << endl << endl;

if (pctUserScore >= pctPassScore) {

cout << "Test Result: Pass" << endl;

}

else {

cout << "Test Result: Fail" << endl;

}

cout <<"User Test Score: "<<userScore<<endl;

cout <<"User Percent Score: "<<pctUserScore<<" %"<<endl;

cout <<"Maximum Score: "<<maxScore<<endl;

cout <<"Percent Pass Score: "<<pctPassScore<<" %"<<endl;


}

==========================

SEE OUTPUT

Thanks, PLEASE COMMENT if there is any concern.


Related Solutions

c++ class homework Topics If/Else If statement Description Write a program that determines a student’s final...
c++ class homework Topics If/Else If statement Description Write a program that determines a student’s final grade in the course. The course had three tests (100 points each) and four assignments (also 100 points each). All the test scores make up 70% of the grade and all the assignments 30% of the grade. The program asks the user to input one by one each of the test scores and each of the assignment scores. From these scores, it computes the...
Use c++language Use the pseudocode description below to write a program that uses an if, else...
Use c++language Use the pseudocode description below to write a program that uses an if, else if, else decision structure for a program that will determine if someone lives in Boston. 1. display message that describes what the program will do. 2. ask the user to input an answer to the question: Do you live in Boston?. 3. if they entered 'y', display a message confirming that they live in Boston. 4. if they entered 'n' , display a message...
Topics Loops while Statement Description Write a program that computes the letter grades of students in...
Topics Loops while Statement Description Write a program that computes the letter grades of students in a class from knowing their scores in a test. A student test score varies from 0 to 100. For a student, the program first asks the student’s name and the student’s test score. Then, it displays the student name, the test score and the letter grade. It repeats this process for each student. The user indicates the end of student data by entering two...
Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant future"...
Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant future" (without quotes). Else, if givenYear is 2001 or greater (2001-2100), print "21st century". Else, if givenYear is 1901 or greater (1901-2000), print "20th century". Else (1900 or earlier), print "Long ago". Do NOT end with newline C++
write pseudocode not c program If- else programming exercises 1.    Write a C program to find...
write pseudocode not c program If- else programming exercises 1.    Write a C program to find maximum between two numbers. 2.    Write a C program to find maximum between three numbers. 3.    Write a C program to check whether a number is negative, positive or zero. 4.    Write a C program to check whether a number is divisible by 5 and 11 or not. 5.    Write a C program to check whether a number is even or odd. 6.    Write...
Analysis and Discussion about if, if else, else if statement and Switch C programming write on...
Analysis and Discussion about if, if else, else if statement and Switch C programming write on your computer font
Write in C programming using if and else statements only please!!! Write a program that plays...
Write in C programming using if and else statements only please!!! Write a program that plays the following card game: The user starts out with a pot of $100. At each hand of the game, the dealer and the player are dealt a random number between 1 and 52. The player wins $20 if his/her number is greater than the dealer's number; otherwise they lose $20.
Please write this program in C++ Write a program that           - a user-defined class Cuboid...
Please write this program in C++ Write a program that           - a user-defined class Cuboid which has the following elements:                    - default constructor (has no parameters)                    - constructor that has 3 parameters (height, length, width)                    - data members                              - height, length, width                    - member functions                              - to set the value of each of the data members - 3 functions                              - to get the value of each of the data members - 3...
Assignment Description Write a program that will have a user guess whether a person is a...
Assignment Description Write a program that will have a user guess whether a person is a musician or a writer. You will create a group of four names, two musicians and two writers, and show the user a name randomly selected from the four. The user will then guess whether they think the name belongs to a musician or writer. After a guess, the program will tell the user whether they are correct, repeat the name, and reveal the correct...
JAVA Program 2: In Order Using an IF/ELSE IF/ELSE structure, write a program that will prompt...
JAVA Program 2: In Order Using an IF/ELSE IF/ELSE structure, write a program that will prompt the user for three numbers and displays them in ascending order. First, the program will prompt the user for each of the three numbers. Next, find the smallest value of the three. Then decide which of the other two is the next smallest. Then have the program display the three numbers in ascending order. Be sure to do the following: Determine what the input...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT