Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.138.114.140
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/ranicholson/../bdstamour/../cathomas/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //home/ranicholson/../bdstamour/../cathomas/example1.cpp
//--------------------------------------------------------------------------
//  Example Program #1 - Grade Point Average Report
//
//  Written by K R Ames
//  August 2008
//
//  Purpose:  To calculate a student's cumulative GPA, the number of credit
//            hours he needs to reach the 120 hours required for graduation,
//            and the bonus he'll receive from his rich uncle.
//--------------------------------------------------------------------------

// ----------- Preprocessor Section -----------

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

// --------------- Main Function ---------------

int main ()
{

// ----- Variables and Constants

   const int
      BONUSAMT = 50,  // uncle's bonus is equal to this times gpa
      GRADREQ = 120;  // credits required to graduate

   int
      hoursrem,       // hours student needs to reach gradreq
      credits,        // credit hours accumulated so far
      idnum;          // 4-digit student id code

   float
      qualpts,        // quality points earned so far
      gpa,            // cumulative gpa
      totalbonus;     // total amount of uncle's gift

// ----- Input Phase

   cout << "Enter your 4-digit student id --> ";
   cin >> idnum;
   cout << "Enter your credit hours --------> ";
   cin >> credits;
   cout << "Enter your quality points ------> ";
   cin >> qualpts;

// ----- Processing Phase

   gpa = qualpts / credits;
   hoursrem = GRADREQ - credits;
   totalbonus = gpa * BONUSAMT;

// ----- Output Phase

   cout << fixed;  // force fixed point format for floats

   cout << "\n\n********************************************";
   cout << "\n* SEMESTER GRADE REPORT FOR STUDENT # " << idnum << " *";
   cout << "\n********************************************";
   cout << "\n\n        Credit hours earned:   " << credits;
   cout << setprecision(1);  // one decimal digit for floats
   cout << "\n        Quality points earned: " << qualpts;
   cout << setprecision(2);  // two decimal digits for floats
   cout << "\n        Grade Point Average:   " << gpa;
   cout << "\n\n               Congratulations!";
   cout << "\n\n        You need " << hoursrem << " hours to graduate.";
   cout << "\n\nYour rich uncle will pay you " << totalbonus << " dollars!\n";

   return 0;
}

Stv3n404 - 2023