Class project

I have a class project that requires loops and nested loops...I think it'll be much easier if I showed you:

PLEASE READ CAREFULLY!

At Valence community college, a student can’t take more than 2 courses under the constraint of having no more than 6 credit hours. The purpose of this assignment is to construct a fee invoice for a student. This requires the input of Student’s id as integer and the course numbers.
It costs 120.25 dollars per credit hour in addition to $35.00 charged for health and id services.

Here is the list of all courses Valence Community College offers:

CRN Course Prefix Credit Hours
4587 MAT 236 4
4599 COP 220 3
8997 GOL 124 1
9696 COP 100 3

After inputting all the necessary data (see sample run), a fee invoice as shown below should be printed to the screen.

VALENCE COMMUNITY COLLEGE
ORLANDO FL 10101
---------------------

Fee Invoice Prepared for Student V5656

1 Credit Hour = $120.25

CRN CR_PREFIX CR_HOURS
4599 COP 220 3 $ 360.75
9696 COP 100 3 $ 360.75

Health & id fees $ 35.00

--------------------------------------
Total Payments $ 756.50


See sample run for more details.

Sample Run 1 (The user’s entry is in bold)

Enter the Students Id
5656

Enter how many courses-up to 2
5
Sorry you can’t take more than 2 courses. Try again
2

Enter the 2 course number(s)
4587 9696

Sorry you can’t cumulate more than 6 credit hours!
Enter C/c to enter the course number(s) for this student
Enter P/p to process new student
Enter E/e to exit program
C

Enter the 2 course number(s)
4599 9696


Thank you!
Here is the fee invoice

VALENCE COMMUNITY COLLEGE
ORLANDO FL 10101
---------------------

Fee Invoice Prepared for Student V5656

1 Credit Hour = $120.25

CRN CR_PREFIX CR_HOURS
4599 COP 220 3 $ 360.75
9696 COP 100 3 $ 360.75

Health & id fees $ 35.00

--------------------------------------
Total Payments $ 756.50



Enter P/p to process new student, N/n to exit program
N

Goodbye!

I can get the outloop to do what it's supposed to do but once I try to build the inner loop I just get errors

Last edited on
Valence community college, you do happen to go to Valencia in Orlando do you?
Yeah
Can you help me?
I'll take a look through it, reason I asked the Vallencia question is because I go to DeVry. Give me a little I'll help ya
Oh ok cool, isn't that over by the millenia area?
Yep
Do you know how to use procedures yet?
Or methods i should say since it is C++.
Last edited on
When you get the chance post your code and I'll compare it with mine and help you point out some errors.
No he only want us to use do, while, for loops or if/ else statements.

Here's my code:

#include <iostream>
#include <string>

using namespace std;

int main ()
{
int course1, course2, hours1 , hours2 , classNum , ID , sum;
const double tuition = 120.25;
const double health = 35.00;
char answer = ' ';
string prefix1 , prefix2;
cout.precision(2);
cout<<fixed;

do
{
cout<<"Please enter Student ID : ";
cin>>ID;

do
{
cout<<"\nEnter the Number of courses you plan on taking : ";
cin>>classNum;

while(classNum > 2)
{
cout <<"\nI'm sorry but only two courses are alloted.\nPlease Try Again : ";
cin>>classNum;
}

if (classNum == 1)
{
cout <<"\nPlease enter your course code : ";
cin>>course1;

switch (course1)
{
case 4599: prefix1 ="COP 220";
hours1 = 3;
break;

case 9696: prefix1 = "COP 100";
hours1 = 3;
break;

case 4587: prefix1 = "MAT 236";
hours1 = 4;
break;

case 8997: prefix1 = "GOL 124";
hours1 = 1;
break;

default : cout<<"Invalid Course\n\n";
} //endSwitch

}
else
{
cout<<"\nEnter both course codes : ";
cin>>course1>>course2;

}



cout <<"\nSorry, but no more than 6 credits hours permitted\n\n";

cout <<"\nEnter C enter the course number(s) for this student\n";
cout <<"Enter P to process a new student\n";
cout <<"Enter E to Exit Program : ";
cin>>answer;
}while(toupper(answer)=='C');
}while(toupper(answer)=='P');

if(toupper(answer)=='E');
{
return 0;
}


system ("pause");
}
Help
Any chance you could edit the post with the code in to format it ?
Put a [C0de] tag beore the code and [/C0de] tag (but use o not 0) after (or select and hit the # format button to get code like
1
2
3
4
5
int main()
{
   //This code does nothing!
   return 0;
}

You will probably have to fix the indentation manually.
It makes the code much easier to read, and so greatly improves your chances of helpful responses (and the line numbers help people to pinpoint errors and changes).
Last edited on
Topic archived. No new replies allowed.