A Final Grade Program 2

Ok, now when I run the program..nothing happens. I go through all the inputs but it doesn't show my end outputs. I commented what it doesn't show

#include <iostream>
#include <cmath>
#include<iomanip>
using namespace std;

struct FinalGrade
{
double hw1;
double hw2;
double hw3;
double hw4;
double hw5;
double hw6;
double quiz1;
double quiz2;
double quiz3;
double test1;
double test2;
double ec1;
double ec2;
double ec3;
double ec4;
double ec5;
double finalgrade;
};

int main() {
FinalGrade Sean;
double score = 0.0;

cout << "This program will calculate your final grade for the semester" << endl;

cout << "Enter your grade for Homework 1: " << endl;
cin >> Sean.hw1;

cout << "Enter your grade for Homework 2: " << endl;
cin >> Sean.hw2;

cout << "Enter your grade for Homework 3: " << endl;
cin >> Sean.hw3;

cout << "Enter your grade for Homework 4: " << endl;
cin >> Sean.hw4;

cout << "Enter your grade for Homework 5: " << endl;
cin >> Sean.hw5;

cout << "Enter your grade for Homework 6: " << endl;
cin >> Sean.hw6;

cout << "Enter your grade for Quiz 1: " << endl;
cin >> Sean.quiz1;

cout << "Enter your grade for Quiz 2: " << endl;
cin >> Sean.quiz2;

cout << "Enter your grade for Quiz 3: " << endl;
cin >> Sean.quiz3;

cout << "Enter your grade for Test 1: " << endl;
cin >> Sean.test1;

cout << "Enter your grade for Test 2: " << endl;
cin >> Sean.test2;

cout << "Enter your grade for Extra Credit Assigment 1: " << endl;
cin >> Sean.ec1;

cout << "Enter your grade for Extra Credit Assigment 2: " << endl;
cin >> Sean.ec2;

cout << "Enter your grade for Extra Credit Assigment 3: " << endl;
cin >> Sean.ec3;

cout << "Enter your grade for Extra Credit Assigment 4: " << endl;
cin >> Sean.ec4;

cout << "Enter your grade for Extra Credit Assigment 5: " << endl;
cin >> Sean.ec5;

score += Sean.hw1 + Sean.hw2 + Sean.hw3 + Sean.hw4 + Sean.hw5 + Sean.hw6 + Sean.quiz1 + Sean.quiz2 + Sean.quiz3 + Sean.test1 + Sean.test2 + Sean.ec1 + Sean.ec2 + Sean.ec3 + Sean.ec4 + Sean.ec5;

cout << "Your total score is " << score << endl;// Doesn't Show

if(score == 450 || score > 450)
cout << "You are exempt from the Final Exam" << endl;//Doesn't show
else
cout<< "You are not exempt" << endl;//Doesn't show

return 0;
}

Last edited on
It does display your output. It's just that the system closes the program's window once it has ended, which means you have only several milliseconds to read what's displayed.

To prevent the system from closing the window, include <cstdlib> and add system("pause"); just before return 0;
closed account (3qX21hU5)
Please do not use system("pause"); please read this article about why. http://www.cplusplus.com/forum/articles/11153/

Use this or something like this instead

1
2
3
4
  std::cout << "Press ENTER to continue...";
  std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );

  return 0;


It is ok to use it when you are just messing around with something, but I would just get in the habit of not using it.
Last edited on
^ And what exactly does that do? I want to understand something if I use it
closed account (3qX21hU5)
It does the same thing as system("pause"); does.

Basically it stops the command prompt from closing until the user presses enter.
Last edited on
Topic archived. No new replies allowed.