Question

In: Computer Science

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 percentage of total points obtained by the user. It then determines the user’s final grade according to the table below.

90%-100%      A

80%-89.99%   B

70%-79.99%   C

60%-69.99%   D

0%-59.99%     F

At the end, the program displays a summary report including: the original tests scores, the original assignment scores, the overall percentage points earned by the user and the final grade.

Requirements

Do the assignment using if/else if statement (not multiple if statements)

Test Data

Use the test data in test run 1 and test run 2 below

(input values are in bold)

(It's OK if your output does not show decimal values in exactly the same way.)

Input Test Run 1

Enter Scores Test 1: 90

Enter Scores Test 2: 90

Enter Scores Test 3: 90

Enter Scores Assignment 1: 90

Enter Scores Assignment 2: 90

Enter Scores Assignment 3: 90

Enter Scores Assignment 4: 90

Output Test Run 1

Summary Report

Test Scores:                   90.0, 90.0, 90.0

Assignment Scores:       90.0, 90.0, 90.0, 90.0

Overall Percentage:        90.0%

Final Grade:                   A

Input Test Run 2

Enter Scores Test 1: 70

Enter Scores Test 2: 72

Enter Scores Test 3: 68

Enter Scores Assignment 1: 66

Enter Scores Assignment 2: 68

Enter Scores Assignment 3: 72

Enter Scores Assignment 4: 74

Output Test Run 2

Summary Report

Test Scores:                   70.0, 72.0, 68.0

Assignment Scores:       66.0, 68.0, 72.0, 74.0

Overall Percentage:        70.0%

Final Grade:                   C

Submit

Copy the following in a file and submit that file.

Final output of test runs.

All the C/C++ source code.

Sample Code

/*

Declare variables t1, t2 and t3 for storing test scores and a1, a2, a3 and a4 for storing assignment scores. The variable pct is used for storing overall percentage. The variable grade is used for scoring the final letter grade

*/

double t1, t2, t3, a1, a2, a3, a4, pct;

string grade;

//write code below to input one by one the test and assignment scores in the above variables

//compute the overall percentage scores

pct = ( ( (t1 + t2 + t3 ) / 3.0 ) * .70 ) + ( ( ( a1 + a2 + a3 + a4 ) / 4.0 ) * .30 );

//compute final grade on the basis of pct scores using if/else if statement

if (pct >= 90) {

    grade = "A";

}

else if (pct >= 80) {

    grade = "B";

}

else if (pct >= 70) {

    grade = "C";

}

//complete the above if/else if statement

Solutions

Expert Solution

#include <iostream>

// To set the decimal precision of double upto 1
// To access setprecision() function
#include <iomanip>

using namespace std;

int main()
{
double t1, t2, t3, a1, a2, a3, a4, pct;

//Test Scores input
cout<<" Enter Scores Test 1:";
cin>>t1;
cout<<" Enter Scores Test 2:";
cin>>t2;
cout<<" Enter Scores Test 3:";
cin>>t3;

// Assignment Scores input
cout<<" Enter Scores Assignment 1:";
cin>>a1;
cout<<" Enter Scores Assignment 2:";
cin>>a2;
cout<<" Enter Scores Assignment 3:";
cin>>a3;
cout<<" Enter Scores Assignment 4:";
cin>>a4;

string grade;
pct = ( ( (t1 + t2 + t3 ) / 3.0 ) * .70 ) + ( ( ( a1 + a2 + a3 + a4 ) / 4.0 ) * .30 );

// 90%-100%
if (pct >= 90) {

grade = "A";

}

// 80%-89.99%
else if (pct >= 80) {

grade = "B";

}

// 70%-79.99%
else if (pct >= 70) {

grade = "C";

}

// 60%-69.99%
else if (pct >= 60) {

grade = "D";

}

// 0%-59.99%
else{

grade = "F";

}

   // Setting double precision upto 1 only
    std::cout << std::fixed;
std::cout << std::setprecision(1);


   cout<<"\n Summary Report";
   cout<<"\n Test Scores:\t"<<t1<<", "<<t2<<", "<<t3;
   cout<<"\n Assignment Scores:\t"<<a1<<", "<<a2<<", "<<a3<<", "<<a4;
   cout<<"\n Overall Percentage:\t"<<pct<<"%";
   cout<<"\n Final Grade:\t"<<grade;

return 0;
}

Test Run 1 :

Test Run 2:


Related Solutions

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...
Module/Week 3 ASSIGNMENT (CONTROL STRUCTURES . IF ..ELSE) Write a C++ program that computes a student’s...
Module/Week 3 ASSIGNMENT (CONTROL STRUCTURES . IF ..ELSE) Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file. You must also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score...
Write a program that determines a student’s grade. The program will read three types of scores...
Write a program that determines a student’s grade. The program will read three types of scores (quiz, mid-term, and final scores) and determine the grade based on the following rules: -if the average score =90% =>grade=A -if the average score >= 70% and <90% => grade=B -if the average score>=50% and <70% =>grade=C -if the average score<50% =>grade=F Using Switch Statement Need to code to be simple to understand. No pointers should be used
Lab 3.4 Write a program that determines a student’s grade. The student will enter a grade...
Lab 3.4 Write a program that determines a student’s grade. The student will enter a grade and the program will determine if that grade is an A, B, C, D, or E. The student can only enter number 0-100. A = 90-100 B = 80-89 C = 70-79 D= 60-69 E = 59 or less Save the file as Lab3.4 and submit the file. Use https://repl.it/ THIS LANGUAGE IS PYTHON Thank you :)
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...
C++ Write a program that asks a teacher to input a student’s first name, last name,...
C++ Write a program that asks a teacher to input a student’s first name, last name, and four test scores. The program should find the average of the four test scores and should then write the following information to a file named “students.txt” last_name first_name average A student's first name of “XX” should be used as a sentinel value and no numeric grades less than 0 or greater than 100 should be accepted.  The program should then read the information in...
write a c++ program an expression that determines if an integer, n is a negative four...
write a c++ program an expression that determines if an integer, n is a negative four digit number. write a c++ program an expression that determines if a string, wd, equals "so" ignoring case.
Write a C++ program that reads a string from a text file and determines if the...
Write a C++ program that reads a string from a text file and determines if the string is a palindrome or not using stacks and queue
Write a program in C A teacher will assign homework and give the number of days...
Write a program in C A teacher will assign homework and give the number of days for the students to work on. The student is responsible for calculating the due date. The teacher does not collect homework on Friday or weekend. Write a C program that let the user enter today’s day of the week (0 for Sunday, 1 for Monday, etc.) and the number of days to allow the students to do the work, which may be several weeks....
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