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 :)
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...
C++ Description: You will write a program that reads students names followed by their final grade....
C++ Description: You will write a program that reads students names followed by their final grade. It will output the names and their grade, followed by the corresponding letter grade. It will also print the name of the students(s) with the highest grade Student data will be stored in a struct called studentType which has 4 members: fName lName score letterGrade Assume there are 20 students Your main() function will only have variable definitions and function calls You MUST have...
(Please write in C++) Write a program that reads in a line consisting of a student’s...
(Please write in C++) Write a program that reads in a line consisting of a student’s name, Social Security number, user ID, and password. The program outputs the string in which all the digits of the Social Security number and all the characters in the password are replaced by x. (The Social Security number is in the form 000-00-0000, and the user ID and the password do not contain any spaces.) Your program should not use the operator [ ]...
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT