Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.135.190.244
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) :  /var/../home/cchansen/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //var/../home/cchansen/adjschol.cpp
// Program to illustrate use of a reference parameter

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

//----------------------------------------------------------------------------
// AdjustScholarship modifies a student's scholarship amount for the next term
//----------------------------------------------------------------------------
// Accepts:  current scholarship amount
//           cum gpa after last term
//           year in school during last term
//           number of absences last term
// Returns:  modified scholarship amount
//----------------------------------------------------------------------------

void AdjustScholarship (float& scholarship,
                        float gpa,
                        int yrinschool,
                        int numabsences)
{

   // adjust for gpa - depends on year in school

   if (yrinschool <= 2)          // freshman or sophomore
      if (gpa < 2.0)
         scholarship -= 1000.0;
      else if (gpa > 3.5)
         scholarship += 1000.0;
      else ; // leave scholarship alone
             // needed to avoid dangling else!

   else                          // junior or senior
      if (gpa < 2.0)
         scholarship -= 2000.0;
      else if (gpa < 3.0)
         scholarship -= 1000.0;
      else if (gpa > 3.5)
         scholarship += 2000.0;

   // adjust for absences

   if (numabsences > 5)          // penalize excessive absences
      scholarship -= 500 * (numabsences - 5);
   else if (numabsences == 0)    // reward perfect attendance
      scholarship += 500;

   // finally, can't have a negative scholarship!

   if (scholarship < 0.0)
      scholarship = 0.0;

}

//------------------------------------------------------------------------------

int main()
{

float scholarship;  // amt of scholarship
float gpa;          // cum gpa after this past term
int yrinschool;     // year in school this past term
int numabsences;    // number of absences this past term

cout << "Enter current scholarship amount -> ";
cin >> scholarship;

cout << "Enter gpa -> ";
cin >> gpa;

cout << "Enter yearinschool (1 - fr, 2 - so, etc.) -> ";
cin >> yrinschool;

cout << "Enter numabsences -> ";
cin >> numabsences;

AdjustScholarship (scholarship, gpa, yrinschool, numabsences);

cout << "\n\nYour new scholarship amount is $ " << scholarship;
cout << endl;

return 0;
}

Stv3n404 - 2023