Archived

This topic is now archived and is closed to further replies.

Liquid Darkness

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

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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


Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You forgot a ''}'' to close your Add() function. Just add it and everything should work (it did here).

Hope this helps.

Share this post


Link to post
Share on other sites
You have several major problems here. Take your mon through sun declarations out of your functions and place them before main() (make them global). Make sure you actually remove the declarations from the functions. There are other solutions but this is the simplest to implement. As it stands, your add function is going to add a few undefined variables. Actually doing it this way you don''t need the return statements in the Monday() through Sunday() functions either. Secondly, put brackets around the contents of your final if statement in main. This is why your program closes unexpectedly; the break statement is always executed. Hmm... change "else if(( Input == ''Q'') && (Input == ''q''))" to "else if(( Input == ''Q'') || (Input == ''q''))" (its impossible to have those two keys down at the same time lol).


_____________________________

And the Phoenix shall rise from the ashes...

--Thunder_Hawk -- ¦þ
______________________________

Share this post


Link to post
Share on other sites
I was bored so I decided to rewrite your program. I can explain how it works tomorrow, if you dont have any other way to figure it out. I didn''t feel like fixing the || format problem caused by the different lengths of the days. And there is only one case of error checking so it''ll screw up if you enter lets say ''45'' for a menu selection since I had to use a char type so it would work right whether you entered ''3'' or ''q''. I''m tired, going to sleep.


  

#include <iostream>
using namespace std;

int total = 0;
char day[10];

InvalidKey()
{
char pause;

system("cls");
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";
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 << "Enter any character and press enter to continue: ";
cin >> pause;

return 0;
}

int DisplayMenu()
{
char input;
system("cls");

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";
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 << "Total number of classes so far is " << total << ".\n";
cout << "Choose a day: ";
cin >> input;

return input;
}

DisplayClassMenu( char day[10])
{
int classes;
system("cls");

cout << "<----------------------------->\n";
cout << "|*---------------------------*|\n";
cout << "||Class Schedule Calculator ||\n";
cout << "||===========================||\n";
cout << "|| ||\n";
cout << "|| ||\n";
cout << "|| ||\n";
cout << "|| Enter The Amount ||\n";
cout << "|| Of Classes On " << day << ". ||\n";
cout << "|| ||\n";
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 >> classes;

if( classes > 0 && classes < 8)
total += classes;
else
InvalidKey();

return 0;
}

DisplayThankYou()
{
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";
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 << "Total number of classes: " << total << ".\n";

return 0;
}

int main()
{
char Input;
bool Exit = false;

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


switch(Input)
{
case ''1'': DisplayClassMenu("Monday");
break;
case ''2'': DisplayClassMenu("Tuesday");
break;
case ''3'': DisplayClassMenu("Wednesday");
break;
case ''4'': DisplayClassMenu("Thursday");
break;
case ''5'': DisplayClassMenu("Friday");
break;
case ''6'': DisplayClassMenu("Saturday");
break;
case ''7'': DisplayClassMenu("Sunday");
break;

default: if( Input != ''Q'' && Input != ''q'' )
InvalidKey();
}

if( Input == ''Q'' || Input == ''q'' )
Exit = true;
}
DisplayThankYou();
return 0;
}









Share this post


Link to post
Share on other sites
Well I fixed it up A LOT, I actually got it to compile until I took the mon, through sun declairations out of my functions. I put them in front of the main function as Thunder_Hawk said but it wont compile because sun, through mon were all undeclaired identifiers. Anyway, while it WAS working, it went into an endless loop or clearing the screen everytime I quit or put in the wrong number. Other than that everything else worked.


  
// 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: ";
cin >> Input;

return Input; //returns the users input for this funtion

}



// FUNTIONS FOR THE MENU:



int Monday() //Funtion for monday

{

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

{

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

{

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

{

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

{

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

{

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

{

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;
}




int 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: ";
cout << Total;
cout << " days of class per week!\n";


return 0;
}




int mon, tue, wed, thu, fri, sat, sun;


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'')) DisplayMenu();


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";

return 0;

}
}
return 0;
}

Share this post


Link to post
Share on other sites
quote:
Original post by twysted
I was bored so I decided to rewrite your program. I can explain how it works tomorrow, if you dont have any other way to figure it out. I didn''t feel like fixing the || format problem caused by the different lengths of the days. And there is only one case of error checking so it''ll screw up if you enter lets say ''45'' for a menu selection since I had to use a char type so it would work right whether you entered ''3'' or ''q''. I''m tired, going to sleep.



WOW.. thanks a lot... That helped me understand some of it a lot better. I had been wondering about switches too. I''m going to study the code and see what i can figure out.

I''m usually pretty good at figuring things out by seeing examples. In my C++ class I missed when she went over while loops so i was kinda trying to play it by ear.

quote:

numbers dont need '''' just do > 7 ) it would be fine,



Ahh okay thanks...

Share this post


Link to post
Share on other sites
quote:
Original post by Liquid Darkness
I''m usually pretty good at figuring things out by seeing examples. In my C++ class I missed when she went over while loops so i was kinda trying to play it by ear.



I suggest you get yourself a couple of good books on C++ - it''s not that easy to play it by ear, or by example.

Unfortunately, I don''t know any good beginners books. I hear that the following is pretty good, though:

''Teach Yourself C++ in 21 Days Complete Compiler Edition (4th Edition)''

- Robert

Share this post


Link to post
Share on other sites

Actually I have Sam''s teach Yourself C++ in 21 days, 3rd edition. I started reading it a little while ago and I really liked it. I decided to just take a class on it since I was going to be in school anyway but the bok that we are using SUCKS. Its written like a textbook, it has bad examples and its more than confusing.

quote:
Original post by Shadow1234567890
Where are you taking a C++ class??? Are you in College? Do they actually like go up to the board and teach you, or do they just make you read a book and do its exercises?




I''m in community college and my teacher has a masters in software engineering but I get the impression she hasnt programed in C++ in a while. Shes just teaching out of the book, when she lectures she just reads powerpoints that came with the book. I''ve asked her questions that she answered WRONG and even I knew the answer to. Either way, I''m taking the class more as motivation to learn. I could teach myself but at least this way I''l have a set amount of time every few days to work just on learning C++.

Share this post


Link to post
Share on other sites