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...
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...
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...
Please code in C# - (C - Sharp) Assignment Description Write out a program that will...
Please code in C# - (C - Sharp) Assignment Description Write out a program that will ask the user for their name; the length and width of a rectangle; and the length of a square. The program will then output the input name; the area and perimeter of a rectangle with the dimensions they input; and the area and perimeter of a square with the length they input. Tasks The program needs to contain the following A comment header containing...
Program this in C thank you PROBLEM DESCRIPTION: Write a program to implement the following requirement:...
Program this in C thank you PROBLEM DESCRIPTION: Write a program to implement the following requirement: The program will read from standard input two things - a string str1 on the first line of stdin (this string may be an empty string) - a string str2 on the second line of stdin (this string may be an empty string) Note that stdin does not end with '\n'. The program will output a string that is the concatenation of string str1...
Hotel Occupancy C++ Only Program Description Write a program that calculates the occupancy rate for a...
Hotel Occupancy C++ Only Program Description Write a program that calculates the occupancy rate for a hotel. The program should read its data from a file named "hotel.dat". The first line of this file will be a single integer specifying the number of floors in the hotel. Each of the remaining (N) lines will have two integers; the number of rooms on that floor and the number of occupied rooms on that floor. Your program should display the following: How...
(17pts)Write, compile, and test a C++ program that uses an if-else structure for problem 3.7 on...
(17pts)Write, compile, and test a C++ program that uses an if-else structure for problem 3.7 on page 108.  Use the format specified earlier (initial block of comments with TCC logo, name, etc) Display instructions so that the user understands the purpose of the program and what to enter. Display the results in increasing (non-decreasing) order. Run the program for the following 6 test cases.Turn in a printout of the program and printouts of the 6 test cases.(The result should...
C++: Write correct C++ code for a nested if-else if-else structure that will output a message...
C++: Write correct C++ code for a nested if-else if-else structure that will output a message based on the logic below. A buyer can pay immediately or be billed. If paid immediately, then display "a 5% discount is applied." If billed, then display "a 2% discount is applied" if it is paid in 30 days. If between 30 and 60 days, display "there is no discount." If over 60 days, then display "a 3% surcharge is added to the bill."...
1)Write a C++ program which clearly demonstrates how the dangling else ambiguity is resolved. Your program...
1)Write a C++ program which clearly demonstrates how the dangling else ambiguity is resolved. Your program should print distinct results depending on if C++ uses inner-if or outer-if resolution. Turn in a listing of your program, the output, and a description of how your program demonstrates the semantic resolution of the ambiguity. 2) Give a context-free grammar describing the syntax of the following; Non-empty strings of 0’s and 1’s that represent binary numbers that have odd parity
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT