Site hosted by Angelfire.com: Build your free website today!

  problem 6:c++ 

alternative #1

#include <iostream>
using namespace std;
void main()
{
int gradelevel;
float donation;

while (gradelevel > 4 || gradelevel < 1)
{
cout<<"Please enter one of the following grade levels:\n";
cout<<"1. Freshmen\n";
cout<<"2. Sophmore\n";
cout<<"3. Junior\n";
cout<<"4. Senior\n";
cout<<endl;
cin>>gradelevel;
cout<<endl;
}
cout<<"Please enter the donation amount, without the dollar sign ($): ";cin>>donation;
cout<<endl;
}

alternative #2

#include <iostream>

#include <conio.h>

using namespace std;

 

void main ()

 

{

int freshc = 0, sophc = 0, junc = 0, senc = 0;

int gradelevel;

float donation=0;

//float freshdonation=0, sophdonation=0, jundonation=0, sendonation=0;

cout<<"***NOTE*** enter 999 to quit the program.\n";

            while (gradelevel < 5 || gradelevel > 0 && gradelevel != 999)

            {

cout<<"Please enter the students's class level:\n";

cout<<"1.  Freshmen\n";

cout<<"2.  Sophmore\n";

cout<<"3.  Junior\n";

cout<<"4.  Senior\n";

cout<<endl;

cin>>gradelevel;

switch (gradelevel)

{

case 1: ++freshc;cout<<"Please enter the donation amount: ";cin>>dummydonation;cout<<endl;

            cout<<endl;break;

case 2: ++sophc;cout<<"Please enter the donation amount: ";cin>>dummydonation;cout<<endl;

            cout<<endl;break;

case 3: ++junc;cout<<"Please enter the donation amount: ";cin>>dummydonation;cout<<endl;

            cout<<endl;break;

case 4: ++senc;cout<<"Please enter the donation amount: ";cin>>dummydonation;cout<<endl;

            cout<<endl;break;

case 999: cout<<"Good Bye!";cout<<endl;break;

default: cout<<"Error! Please re-enter.";cout<<endl;

}

            }

            cout<<endl;

cout<<freshdonation;

}