My second C++ program and I dont know what to do...

Started by
17 comments, last by Liquid Darkness 21 years, 7 months ago
Well I'm taking a C++ class and I already have a good basis for how C++ works, but our second project in the class has me a bit stumped. I'm a bit lost on how loops work and I cant make out how to fix my errors. 9 times it says, "term does not evaluate to a function" and I have one, "illegal break". I'm not sure of the "right way" to use a break, and I dont know how to get my terms to go to the functions. Heres my code if anyone can figure it out I'd really apriciate it...
    
// This is a Class Schedule Calculation program that should let you input

// a number of classes for each day and then tally up the total classes and 

// display the ammount when you quit the program.



#include <iostream>
using namespace std;


int DisplayMenu()  //creates a funtion to display the menu

{
      int Input;  //declairing a variable


	  system("cls");  //clears the screen


	cout << "<----------------------------->\n";
	cout << "|*---------------------------*|\n";
	cout << "||Class Schedule Calculator  ||\n";
	cout << "||===========================||\n";
	cout << "|| 1) Monday                 ||\n";
	cout << "|| 2) Tuesday                ||\n";
	cout << "|| 3) Wednesday              ||\n";
	cout << "|| 4) Thursday               ||\n";
	cout << "|| 5) friday                 ||\n";
	cout << "|| 6) Saterday               ||\n";    //Menu Interface

	cout << "|| 7) Sunday                 ||\n";
	cout << "|| Q) Quit                   ||\n";
	cout << "||===========================||\n";
	cout << "|*---------------------------*|\n";
	cout << "|  _   _   _   _     -------  |\n";
	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";
	cout << "|  =   =   =   =     =======  |\n";
	cout << "| [5] [6] [7] [Q]             |\n";
	cout << "|  -   -   -   -              |\n";
	cout << "|_____________________________|\n";
	cout << " V___________________________V \n";
    cout << "Choose a day: \n";
	cin >> Input;
      
	return Input;   //returns the users input for this funtion

}



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


// FUNTIONS FOR THE MENU:



void Monday()   //Funtion for monday

{
	int mon;
	system("cls");  //clear the screen


	cout << "<----------------------------->\n";
	cout << "|*---------------------------*|\n";
	cout << "||Class Schedule Calculator  ||\n";
	cout << "||===========================||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||    Enter The Ammount      ||\n";
	cout << "||  Of Classes On Monday:    ||\n";
	cout << "||                           ||\n";   //message to the user

	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||===========================||\n";
	cout << "|*---------------------------*|\n";
	cout << "|  _   _   _   _     -------  |\n";
	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";
	cout << "|  =   =   =   =     =======  |\n";
	cout << "| [5] [6] [7] [Q]             |\n";
	cout << "|  -   -   -   -              |\n";
	cout << "|_____________________________|\n";
	cout << " V___________________________V \n";
	cout << "Classes: ";
	cin >> mon;
}

void Tuesday()   //Funtion for Tuesday

{
	int tue;
	system("cls");  //clear the screen


	cout << "<----------------------------->\n";
	cout << "|*---------------------------*|\n";
	cout << "||Class Schedule Calculator  ||\n";
	cout << "||===========================||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||    Enter The Ammount      ||\n";
	cout << "||  Of Classes On Tuesday:   ||\n";
	cout << "||                           ||\n";   //message to the user

	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||===========================||\n";
	cout << "|*---------------------------*|\n";
	cout << "|  _   _   _   _     -------  |\n";
	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";
	cout << "|  =   =   =   =     =======  |\n";
	cout << "| [5] [6] [7] [Q]             |\n";
	cout << "|  -   -   -   -              |\n";
	cout << "|_____________________________|\n";
	cout << " V___________________________V \n";
	cout << "Classes: ";
	cin >> tue;
}

void Wednesday()   //Funtion for Wednesday

{
	int wed;
	system("cls");  //clear the screen


	cout << "<----------------------------->\n";
	cout << "|*---------------------------*|\n";
	cout << "||Class Schedule Calculator  ||\n";
	cout << "||===========================||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||    Enter The Ammount      ||\n";
	cout << "|| Of Classes On Wednesday:  ||\n";
	cout << "||                           ||\n";   //message to the user

	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||===========================||\n";
	cout << "|*---------------------------*|\n";
	cout << "|  _   _   _   _     -------  |\n";
	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";
	cout << "|  =   =   =   =     =======  |\n";
	cout << "| [5] [6] [7] [Q]             |\n";
	cout << "|  -   -   -   -              |\n";
	cout << "|_____________________________|\n";
	cout << " V___________________________V \n";
	cout << "Classes: ";
	cin >> wed;
}


void Thursday()   //Funtion for Thursday

{
	int thu;
	system("cls");  //clear the screen


	cout << "<----------------------------->\n";
	cout << "|*---------------------------*|\n";
	cout << "||Class Schedule Calculator  ||\n";
	cout << "||===========================||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||    Enter The Ammount      ||\n";
	cout << "||  Of Classes On Thursday:  ||\n";
	cout << "||                           ||\n";   //message to the user

	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||===========================||\n";
	cout << "|*---------------------------*|\n";
	cout << "|  _   _   _   _     -------  |\n";
	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";
	cout << "|  =   =   =   =     =======  |\n";
	cout << "| [5] [6] [7] [Q]             |\n";
	cout << "|  -   -   -   -              |\n";
	cout << "|_____________________________|\n";
	cout << " V___________________________V \n";
	cout << "Classes: ";
	cin >> thu;
}



void Friday()   //Funtion for Friday

{
	int fri;
	system("cls");  //clear the screen


	cout << "<----------------------------->\n";
	cout << "|*---------------------------*|\n";
	cout << "||Class Schedule Calculator  ||\n";
	cout << "||===========================||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||    Enter The Ammount      ||\n";
	cout << "||  Of Classes On Friday:    ||\n";
	cout << "||                           ||\n";   //message to the user

	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||===========================||\n";
	cout << "|*---------------------------*|\n";
	cout << "|  _   _   _   _     -------  |\n";
	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";
	cout << "|  =   =   =   =     =======  |\n";
	cout << "| [5] [6] [7] [Q]             |\n";
	cout << "|  -   -   -   -              |\n";
	cout << "|_____________________________|\n";
	cout << " V___________________________V \n";
	cout << "Classes: ";
	cin >> fri;
}

void Saterday()   //Funtion for Saterday

{
	int sat;
	system("cls");  //clear the screen


	cout << "<----------------------------->\n";
	cout << "|*---------------------------*|\n";
	cout << "||Class Schedule Calculator  ||\n";
	cout << "||===========================||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||    Enter The Ammount      ||\n";
	cout << "||  Of Classes On Saterday:  ||\n";
	cout << "||                           ||\n";   //message to the user

	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||===========================||\n";
	cout << "|*---------------------------*|\n";
	cout << "|  _   _   _   _     -------  |\n";
	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";
	cout << "|  =   =   =   =     =======  |\n";
	cout << "| [5] [6] [7] [Q]             |\n";
	cout << "|  -   -   -   -              |\n";
	cout << "|_____________________________|\n";
	cout << " V___________________________V \n";
	cout << "Classes: ";
	cin >> sat;
}


void Sunday()   //Funtion for Sunday

{
	int sun;
	system("cls");  //clear the screen


	cout << "<----------------------------->\n";
	cout << "|*---------------------------*|\n";
	cout << "||Class Schedule Calculator  ||\n";
	cout << "||===========================||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||    Enter The Ammount      ||\n";
	cout << "||  Of Classes On Sunday:    ||\n";
	cout << "||                           ||\n";   //message to the user

	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||===========================||\n";
	cout << "|*---------------------------*|\n";
	cout << "|  _   _   _   _     -------  |\n";
	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";
	cout << "|  =   =   =   =     =======  |\n";
	cout << "| [5] [6] [7] [Q]             |\n";
	cout << "|  -   -   -   -              |\n";
	cout << "|_____________________________|\n";
	cout << " V___________________________V \n";
	cout << "Classes: ";
	cin >> sun;
}




void Quit()   //Funtion for Quit

{

	int Total, mon, tue, wed, thu, fri, sat, sun;   //declaire variable


	Total = (mon+tue+wed+thu+fri+sat+sun);  //add up the classes


	system("cls");  //clear the screen


	cout << "<----------------------------->\n";
	cout << "|*---------------------------*|\n";
	cout << "||Class Schedule Calculator  ||\n";
	cout << "||===========================||\n";
	cout << "||                           ||\n";
	cout << "||    Thanks For Using       ||\n";
	cout << "||   The Class Schedule      ||\n";
	cout << "||       Calculator...       ||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";   //message to the user

	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||===========================||\n";
	cout << "|*---------------------------*|\n";
	cout << "|  _   _   _   _     -------  |\n";
	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";
	cout << "|  =   =   =   =     =======  |\n";
	cout << "| [5] [6] [7] [Q]             |\n";
	cout << "|  -   -   -   -              |\n";
	cout << "|_____________________________|\n";
	cout << " V___________________________V \n";
	cout << "You have: ";
	cin >> Total;                                    // display the total amount of classes per week

	cout << "classes per week.../n";
	
	break;
}


void InvalidKey()   //Funtion for when somone enters a key that is not on the menu

{
	system("cls");  //clear the screen


	cout << "<----------------------------->\n";
	cout << "|*---------------------------*|\n";
	cout << "||Class Schedule Calculator  ||\n";
	cout << "||===========================||\n";
	cout << "||                           ||\n";
	cout << "||                           ||\n";
	cout << "||  Sorry, but that choice   ||\n";
	cout << "||   is not on the menu...   ||\n";
	cout << "||                           ||\n";
	cout << "||     Choose 1-7, or Q      ||\n";   //message to the user

	cout << "||     ----------------      ||\n";
	cout << "||                           ||\n";
	cout << "||===========================||\n";
	cout << "|*---------------------------*|\n";
	cout << "|  _   _   _   _     -------  |\n";
	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";
	cout << "|  =   =   =   =     =======  |\n";
	cout << "| [5] [6] [7] [Q]             |\n";
	cout << "|  -   -   -   -              |\n";
	cout << "|_____________________________|\n";
	cout << " V___________________________V \n";

}




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

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




int main()   // The main function

{
      int Input, Monday, Tuesday, Wednesday, Thursday, Friday, Saterday, 
		  Sunday, Quit, InvalidKey, mon, tue, wed, thu, fri, sat, sun;  //declaire variable

 
	  while(1)  //while loop

      {
           Input =  DisplayMenu(); //get the value DisplayMenu returned


		   if( Input == 1) Monday();
           else if( Input == 2) Tuesday();
		   else if( Input == 3) Wednesday();     // Take what the user chose

		   else if( Input == 4) Thursday();      // and go to the corisponding function

		   else if( Input == 5) Friday();
		   else if( Input == 6) Saterday();
		   else if( Input == 7) Sunday();

		   else if(( Input == 'Q') && (Input == 'q')) Quit();
		   else if((Input > '7') && (Input != 'Q') && (Input != 'q')) InvalidKey();
	
      }
      return 0;
}




    
[edited by - Liquid Darkness on August 31, 2002 11:53:33 PM]
=-=-=-=-=-=-=-=-=-=-=-=-----I am a signature virus. Please add me to your signature so that I may multiply.
Advertisement
Your message ''does not evaluate to a function'' does say exactly that - a particular term (or expression, or ''piece of code'') should be a function, but it is not. The reason for this is that you have a naming conflict.

In your main routine, there is a variable called ''Monday'', and you have a function called ''Monday''. Now you try to call something named Monday from main. The compiler tries to figure out "What the heck is monday". So it starts searching for definitions of Monday. First, it tries inside the while loop, since this is where you call Monday. No luck though, no Monday defined there. So it goes outside of that block, and it finds a Monday.

But that Monday is an integer variable, and the Monday it is looking for should be a function. After all, you wrote ''Monday()'' in your code, indicating you want to call a function named Monday. Now your compiler is confused. And since it doesn''t know what to do, it lets you know that the Monday it found is not a function.

So if you get rid of all the Monday, Tuesday... variables, everything works fine. Why did you put them there in the first place?

As for the ''illegal break'' message, your Quit() has a break statement in there. Did your teacher explain the use of break yet? If so, he probably explained you can only use it inside a loop. Quit() does not have a loop though. I assume you want to break out of the while in main(), but again, a compile is not as smart as we wish it would be. If it doesn''t find a loop in the current function that it can break out of, it will complain. It will not search in other functions.

(The simple reason for that is that it then would have to look in ALL functions that call Quit(). And what if some of them didn''t have a loop?)

So you need to move the break statement into the main while loop.

Hope that helps,
- Robert


First, some tips.

Your if statements should be "properly" formatted.


  if(condition == true)    DoSomething();else if(anotherCondition == true)    DoSomethingElse();else    DoAnotherSomethingElse();  


Second, a key thing to remember about computer programming is that computers exist to eliminate mundain repetitive actions. With this in mind you should eliminate all the different day methods. Instead have a single method which accepts a string as the name of the day. Then just use that string when outputting your nice ascii art. Remember to consider the length of the string!

Now, for the break thing. Breaks do not work accross methods. In order to fix your problem you should have a boolean variable. Call it "exit". Instead of saying break you would say exit = true;
And instead of while(1) you would say while(exit == false) or while(!exit)

Give those two things a try!

-SniperBoB-

What if The Matrix was recursive?
Wow.

Is it part of the implementation requirements that you must use separate functions for all the weekday functions you have? If it is not, you should definately consider another approach to this since you are always displaying the same interface except one line. Consider a change in the interface (an extra option) would need to be added in each function. Ouch.

I was going to compile this all but I was getting a little tired of separating out all the lines . So I will just say on the break statement that break is only good to break out of a loop for which you have scope in. Your Quit() function, the only place I saw a break, does not have the ability to break out of the loop started in main() directly. An easy way to accomplish what you are looking to do is in your if statement that calls Quit(), also break there. That will break you out of your infinite loop. By the way, looks like if you are really wanting to use your current approach you need to make use of global variables. But I''m not sure what your project requires.

Good Luck.
The problem is that you have functions called Sunday, Monday, Tuesday, etc, Quit, InvalidKey, and you also have variables with the same name. You therefore have to rename either the functions or variables. In the example program, it doesn''t appear that you need them anyway.
quote:Original post by SnprBoB86
First, some tips.

Your if statements should be "properly" formatted.


Ugh - that''s a religious debate. Don''t burden a poor guy who''s just new to the party with all that baggage. Let''s just say there''s quite a few ways to write if statements. And if you have to use a new line, do yourself a favor and use braces.

Otherwise you /will/ forget that it belongs to the if above and does not have braces. You will add a second line, just like this:



    if(condition == true)     DoSomething();    DoSomeOtherThing();    


And it will DoSomeOtherThing all the time....

quote:
Second, a key thing to remember about computer programming is that computers exist to eliminate mundain repetitive actions. With this in mind you should eliminate all the different day methods.


Right on! If you have duplicate lines of code, you might consider changing that. Duplication always hurts.

quote:
Instead have a single method which accepts a string as the name of the day. Then just use that string when outputting your nice ascii art. Remember to consider the length of the string!

And if you don''t want to fight with the wonders of C++ output formatting to get the different lengths just so, pass in a whole line to that routine, containing the proper ASCII art for the one line that has the day name in there.

Rock on!

- Robert

I don''t really see any syntax errors(I didn''t comb throught he code though =) ) but what I do see(even if you fix you current problems) that wrong is:

Your quit function wont work at all. Break statements exit the inner most loop in the current code block(in this case a function) you''re in. In the quit function, calling break while not in a loop has no effect. You have to call break back in the main()function after you call Quit().

Having the break where it is might be the cause of the compile error though.

Also your if statement to see if the user pressed a lower/upper case letter wont work either since you use the logical and operator. Basically, it wont evulate to true unless the user inputted both a lower and upper case Q which is impossible. They can only key in one or the other. Use the logical or ( || ) operator.
"Ogun's Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.
Hello,

groby is exactly right, but to be a bit more specific...

You are getting 9 "invalid function call" errors. That is due to the nine variables that you have named the same as your functions(the seven days plus Quit and Invalid key)

Other than that he did a fine job explaining your problem.

Good work groby

EDIT - That should have been the second reply. These posts come in quicker than you'd think!


"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I'm reaching up and reaching out. I'm reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one's been. We'll ride the spiral to the end and may just go where no one's been." - Maynard James Keenan [TheBlackJester ]
[Wildfire Studios ]

[edited by - TheBlackJester on August 31, 2002 12:26:31 AM]

"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I'm reaching up and reaching out. I'm reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one's been. We'll ride the spiral to the end and may just go where no one's been." - Maynard James Keenan Name: [email=darkswordtbj@hotmail.com]TheBlackJester[/email]Team: Wildfire Games
Projects O A.D.The Last Alliance

Wow, that was fast... I have frequented the Lounge for the last 2 years or so and have only posted in here once or twice but it never fails that everyone will be quik to jump on the problem and lend a helping hand. Thanks a lot guys! I''ll work through my code and see what i come up with. My teacher actually hasnt gone over breaks yet but I needed a way to end my program. I asked a friend and he said to use a break.

As far as all the extra variables, I went through and added them in hope of fixing my problem. Before I put them in I was getting 9 DIFFERENT errors. I''ll see what I can do.
=-=-=-=-=-=-=-=-=-=-=-=-----I am a signature virus. Please add me to your signature so that I may multiply.
Man.. I got rid of all those errors and my rogram ran for the first time.. but then it just ended after I went through the monday function. I rearranged some stuff and changed somethings and now I only have 2 errors. Man I really think I'm making this more complicated than it should be. We havnt gotten to strings or anything and I can only use iostream.

heres my code... I'm getting an "unexpected end of file found" and "'main' : local function definitions are illegal"

i'm pretty sure the unexpected end of file is because I moved my quit section into main. I dunno...


    // This is a Class Schedule Calculation program that should let you input// a number of classes for each day and then tally up the total classes and // display the ammount when you quit the program.#include <iostream>using namespace std;int DisplayMenu()  //creates a funtion to display the menu{      int Input;  //declairing a variable	  system("cls");  //clears the screen	cout << "<----------------------------->\n";	cout << "|*---------------------------*|\n";	cout << "||Class Schedule Calculator  ||\n";	cout << "||===========================||\n";	cout << "|| 1) Monday                 ||\n";	cout << "|| 2) Tuesday                ||\n";	cout << "|| 3) Wednesday              ||\n";	cout << "|| 4) Thursday               ||\n";	cout << "|| 5) friday                 ||\n";	cout << "|| 6) Saterday               ||\n";    //Menu Interface	cout << "|| 7) Sunday                 ||\n";	cout << "|| 8) Add Them All Up!!      ||\n";	cout << "|| Q) Quit                   ||\n";	cout << "|*---------------------------*|\n";	cout << "|  _   _   _   _     -------  |\n";	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";	cout << "|  =   =   =   =     =======  |\n";	cout << "| [5] [6] [7] [Q]             |\n";	cout << "|  -   -   -   -              |\n";	cout << "|_____________________________|\n";	cout << " V___________________________V \n";    cout << "Choose a day: \n";	cin >> Input;      	return Input;   //returns the users input for this funtion}// FUNTIONS FOR THE MENU:int Monday()   //Funtion for monday{	int mon;	system("cls");  //clear the screen	cout << "<----------------------------->\n";	cout << "|*---------------------------*|\n";	cout << "||Class Schedule Calculator  ||\n";	cout << "||===========================||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||    Enter The Ammount      ||\n";	cout << "||  Of Classes On Monday:    ||\n";	cout << "||                           ||\n";   //message to the user	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||===========================||\n";	cout << "|*---------------------------*|\n";	cout << "|  _   _   _   _     -------  |\n";	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";	cout << "|  =   =   =   =     =======  |\n";	cout << "| [5] [6] [7] [Q]             |\n";	cout << "|  -   -   -   -              |\n";	cout << "|_____________________________|\n";	cout << " V___________________________V \n";	cout << "Classes: ";	cin >> mon;	return mon;}int Tuesday()   //Funtion for Tuesday{	int tue;	system("cls");  //clear the screen	cout << "<----------------------------->\n";	cout << "|*---------------------------*|\n";	cout << "||Class Schedule Calculator  ||\n";	cout << "||===========================||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||    Enter The Ammount      ||\n";	cout << "||  Of Classes On Tuesday:   ||\n";	cout << "||                           ||\n";   //message to the user	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||===========================||\n";	cout << "|*---------------------------*|\n";	cout << "|  _   _   _   _     -------  |\n";	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";	cout << "|  =   =   =   =     =======  |\n";	cout << "| [5] [6] [7] [Q]             |\n";	cout << "|  -   -   -   -              |\n";	cout << "|_____________________________|\n";	cout << " V___________________________V \n";	cout << "Classes: ";	cin >> tue;	return tue;}int Wednesday()   //Funtion for Wednesday{	int wed;	system("cls");  //clear the screen	cout << "<----------------------------->\n";	cout << "|*---------------------------*|\n";	cout << "||Class Schedule Calculator  ||\n";	cout << "||===========================||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||    Enter The Ammount      ||\n";	cout << "|| Of Classes On Wednesday:  ||\n";	cout << "||                           ||\n";   //message to the user	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||===========================||\n";	cout << "|*---------------------------*|\n";	cout << "|  _   _   _   _     -------  |\n";	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";	cout << "|  =   =   =   =     =======  |\n";	cout << "| [5] [6] [7] [Q]             |\n";	cout << "|  -   -   -   -              |\n";	cout << "|_____________________________|\n";	cout << " V___________________________V \n";	cout << "Classes: ";	cin >> wed;	return wed;}int Thursday()   //Funtion for Thursday{	int thu;	system("cls");  //clear the screen	cout << "<----------------------------->\n";	cout << "|*---------------------------*|\n";	cout << "||Class Schedule Calculator  ||\n";	cout << "||===========================||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||    Enter The Ammount      ||\n";	cout << "||  Of Classes On Thursday:  ||\n";	cout << "||                           ||\n";   //message to the user	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||===========================||\n";	cout << "|*---------------------------*|\n";	cout << "|  _   _   _   _     -------  |\n";	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";	cout << "|  =   =   =   =     =======  |\n";	cout << "| [5] [6] [7] [Q]             |\n";	cout << "|  -   -   -   -              |\n";	cout << "|_____________________________|\n";	cout << " V___________________________V \n";	cout << "Classes: ";	cin >> thu;	return thu;}int Friday()   //Funtion for Friday{	int fri;	system("cls");  //clear the screen	cout << "<----------------------------->\n";	cout << "|*---------------------------*|\n";	cout << "||Class Schedule Calculator  ||\n";	cout << "||===========================||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||    Enter The Ammount      ||\n";	cout << "||  Of Classes On Friday:    ||\n";	cout << "||                           ||\n";   //message to the user	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||===========================||\n";	cout << "|*---------------------------*|\n";	cout << "|  _   _   _   _     -------  |\n";	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";	cout << "|  =   =   =   =     =======  |\n";	cout << "| [5] [6] [7] [Q]             |\n";	cout << "|  -   -   -   -              |\n";	cout << "|_____________________________|\n";	cout << " V___________________________V \n";	cout << "Classes: ";	cin >> fri;	return fri;}int Saterday()   //Funtion for Saterday{	int sat;	system("cls");  //clear the screen	cout << "<----------------------------->\n";	cout << "|*---------------------------*|\n";	cout << "||Class Schedule Calculator  ||\n";	cout << "||===========================||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||    Enter The Ammount      ||\n";	cout << "||  Of Classes On Saterday:  ||\n";	cout << "||                           ||\n";   //message to the user	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||===========================||\n";	cout << "|*---------------------------*|\n";	cout << "|  _   _   _   _     -------  |\n";	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";	cout << "|  =   =   =   =     =======  |\n";	cout << "| [5] [6] [7] [Q]             |\n";	cout << "|  -   -   -   -              |\n";	cout << "|_____________________________|\n";	cout << " V___________________________V \n";	cout << "Classes: ";	cin >> sat;	return sat;}int Sunday()   //Funtion for Sunday{	int sun;	system("cls");  //clear the screen	cout << "<----------------------------->\n";	cout << "|*---------------------------*|\n";	cout << "||Class Schedule Calculator  ||\n";	cout << "||===========================||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||    Enter The Ammount      ||\n";	cout << "||  Of Classes On Sunday:    ||\n";	cout << "||                           ||\n";   //message to the user	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||===========================||\n";	cout << "|*---------------------------*|\n";	cout << "|  _   _   _   _     -------  |\n";	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";	cout << "|  =   =   =   =     =======  |\n";	cout << "| [5] [6] [7] [Q]             |\n";	cout << "|  -   -   -   -              |\n";	cout << "|_____________________________|\n";	cout << " V___________________________V \n";	cout << "Classes: ";	cin >> sun;	return sun;}void InvalidKey()   //Funtion for when somone enters a key that is not on the menu{	system("cls");  //clear the screen	cout << "<----------------------------->\n";	cout << "|*---------------------------*|\n";	cout << "||Class Schedule Calculator  ||\n";	cout << "||===========================||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||  Sorry, but that choice   ||\n";	cout << "||   is not on the menu...   ||\n";	cout << "||                           ||\n";	cout << "||     Choose 1-7, or Q      ||\n";   //message to the user	cout << "||     ----------------      ||\n";	cout << "||                           ||\n";	cout << "||===========================||\n";	cout << "|*---------------------------*|\n";	cout << "|  _   _   _   _     -------  |\n";	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";	cout << "|  =   =   =   =     =======  |\n";	cout << "| [5] [6] [7] [Q]             |\n";	cout << "|  -   -   -   -              |\n";	cout << "|_____________________________|\n";	cout << " V___________________________V \n";}void Add() //Function to add all the days together{	int Total, mon, tue, wed, thu, fri, sat, sun;	Total = (mon+tue+wed+thu+fri+sat+sun); //Add all the days together	system("cls");  //clears the screen	cout << "<----------------------------->\n";	cout << "|*---------------------------*|\n";	cout << "||Class Schedule Calculator  ||\n";	cout << "||===========================||\n";	cout << "|| 1) Monday                 ||\n";	cout << "|| 2) Tuesday                ||\n";	cout << "|| 3) Wednesday              ||\n";	cout << "|| 4) Thursday               ||\n";	cout << "|| 5) friday                 ||\n";	cout << "|| 6) Saterday               ||\n";    //Menu Interface	cout << "|| 7) Sunday                 ||\n";	cout << "|| 8) Add Them All Up!!      ||\n";	cout << "|| Q) Quit                   ||\n";	cout << "|*---------------------------*|\n";	cout << "|  _   _   _   _     -------  |\n";	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";	cout << "|  =   =   =   =     =======  |\n";	cout << "| [5] [6] [7] [Q]             |\n";	cout << "|  -   -   -   -              |\n";	cout << "|_____________________________|\n";	cout << " V___________________________V \n";    cout << "You have: \n";	cout << Total;	cout << " days of class per week!\n";int main()   // The main function{      int Input;  //declaire variable 	  while(1)  //while loop      {           Input =  DisplayMenu(); //get the value DisplayMenu returned		   if( Input == 1) Monday();           else if( Input == 2) Tuesday();		   else if( Input == 3) Wednesday();     // Take what the user chose		   else if( Input == 4) Thursday();      // and go to the corisponding function		   else if( Input == 5) Friday();		   else if( Input == 6) Saterday();		   else if( Input == 7) Sunday();		   else if( Input == 8) Add();		   else if((Input > '7') && (Input != 'Q') && (Input != 'q')) InvalidKey();			   		   else if(( Input == 'Q') && (Input == 'q'))		cout << "<----------------------------->\n";	cout << "|*---------------------------*|\n";	cout << "||Class Schedule Calculator  ||\n";	cout << "||===========================||\n";	cout << "||                           ||\n";	cout << "||    Thanks For Using       ||\n";	cout << "||   The Class Schedule      ||\n";	cout << "||       Calculator...       ||\n";	cout << "||                           ||\n";	cout << "||                           ||\n";   //message to the user	cout << "||                           ||\n";	cout << "||                           ||\n";	cout << "||===========================||\n";	cout << "|*---------------------------*|\n";	cout << "|  _   _   _   _     -------  |\n";	cout << "| [1] [2] [3] [4]   ( ENTER ) |\n";	cout << "|  =   =   =   =     =======  |\n";	cout << "| [5] [6] [7] [Q]             |\n";	cout << "|  -   -   -   -              |\n";	cout << "|_____________________________|\n";	cout << " V___________________________V \n";			  	break;      }      return 0;}    


[edited by - Liquid Darkness on September 1, 2002 1:19:44 AM]
=-=-=-=-=-=-=-=-=-=-=-=-----I am a signature virus. Please add me to your signature so that I may multiply.

This topic is closed to new replies.

Advertisement