help with my assignment

This is a discussion on help with my assignment within the C++ Programming forums, part of the General Programming Boards category; I have been teaching myself c++ from scratch for the past 4 weeks, as my teachers are crappy. I have ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    25

    help with my assignment

    I have been teaching myself c++ from scratch for the past 4 weeks, as my teachers are crappy. I have an assignment due for early May....

    I need help with writing a program that will enter and validate dates CORRECTLY.

    how can this be done when there are different numbers of days in each month ?............etc

    Can someone help me out

    Here is my assignment as it stand so far....






    Code:
    #include <iostream.h>
    
    #include <conio.h>
    
    void WeeklySales(); //we make weeklysales a function here too
    void datefunc();
    
    main()
    	{
       	int number;
    
          do
          	{      //displays the menu
             	cout << "******Sales System******";
                cout << ("\n\n");
          		cout << "1. Display Company Logo.\n"; endl;
          		cout << "2. Input/Validate weekly sales data.\n";endl;
          		cout << "3. Calculate weekly sales.\n";endl;
          		cout << "4. Display reciept.\n";endl;
          		cout << "5. SHUT DOWN & LOG OFF.\n";endl;
    				cout << "\nEnter number...\n";endl;
             	cin >> number;
                cout << ("\n\n");
    
          		switch (number)  //<--the expression is a variable (number) & controls the switch
                //the value of (number) is tested against a list of constants.
                //When a match is found, the statement sequence assosciated with that match is executed
                   {
          				case 1:    //<-----  const = 1
    
                			cout << ("\n\tUU\tUU \tEEEEEEEE \tLL\t\t \SSSSSSS\n\tUU\tUU \tEE \t\tLL\t\tS\n\tUU\tUU \tEE \t\tLL\t\tS\n\tUU\tUU \tEEEEEEE \t\LL\t\t\ SSSSSS\n\tUU\tUU \tEE \t\tLL\t\t       S\n\tUU\tUU  \tEE  \t  \t\LL  \t\t       S \n\t UUUUUUUU   *\tEEEEEEEE  *\tLLLLLLL  *\tSSSSSSS   *\n\n\n\n\n");break;
    
                		case 2:   //<------const = 2. if match found, executes, then calls the weeklysales function below
    
                			cout << ("Weekly sales data\n\----------------- ");
                                    WeeklySales();  //<-------------   function call here
                                    break;
    
                		case 3:
    
                			cout << ("Calculate weekly sales "); break;
    
                		case 4:
    
                			cout << ("Display receipt "); break;
    
                		case 5:
    
                			cout << ("Goodbye, and thank you for using U.E.L.S. ");break;
    
                      //default statement sequence is executed if no matches are found
                		default:
    
                			cout << ("Enter a number from 1-5 only!");
    
             		}
          	} while (number !=5); //program will NOT stop looping till 5 is entered
          getch();
       }
    
    void WeeklySales() //<--------weekly sales function not part of main() function
    {                  //when function is completed, goes back to case 3:
    //declare variables
    	int salescode, bikeprice, modelcode, quantity, date;
    
       do
            //the instructions to enter the i.d. code will be repeated (do...while
            //loop) as long as the salescode is less than 1 or greater than 20.
       	{
    
          	cout << "\n\nPlease enter your identifiction code ";
             cin >> salescode;
    
             //the condition is tested
             if (salescode < 1 || salescode > 20)
    
             	{
                	cout << ("\nTHIS I.D. CODE IS NOT VALID. TRY AGAIN \n");
                }
          }
    	//the instructions to enter the i.d. code will be repeated (do...while
       //loop) as long as the salescode is less than 1 or greater than 20.
       while (1 > salescode || salescode > 20);
    
       //another do...while loop
       do
       	{
          	cout << "\nPlease enter the bike price (one unit = 1 Euro) ";
          	cin >> bikeprice;
    
             if (bikeprice < 1 || bikeprice > 500)
    
             	{
                	cout << ("\nINVALID PRICE. Bike prices cannot be 0 or more than 500. TRY AGAIN \n");
                }
          }
    
       while (bikeprice < 1 || bikeprice > 500);
    
       //another do...while loop
       do
       	{
          	cout << "\nPlease enter the 3 digit model code ";
          	cin >> modelcode;
    
             if (modelcode < 0 || modelcode > 999)
    
             	{
                	cout << ("\nINVALID MODEL CODE. TRY AGAIN \n");
                }
          }
    
       while (modelcode < 0 || modelcode > 999);
    
       //another do...while loop
       do
       	{
             cout << ("\nPlease enter the quantity sold ");
          	cin >> quantity;
    
             if (quantity < 1 || quantity > 10)
    
             {
             	cout << ("\nINVALID QUANTITY. TRY A NUMBER FROM 1-10 \n");
             }
          }
    
       while (quantity < 1 || quantity > 10);
    
          	cout << "\nPress enter to enter the date ";
             cin >> date;
    
             datefunc();
    
    
            	cout << ("\n\n\n\n\n\n");
    }
    
    void datefunc()
    {

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I have no idea how, if at all, this date function is supposed to tie into anything else in the code you posted. I'm guessing you've read enough "post code" posts to realize you needed to post some code. So now we'll change the mantra:

    Post code that has something to do with your problem.

    As to the question you ask, you can't validate day-of-month separately from the month, since as you say there are different numbers of days in different months.

  3. #3
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    stopped reading after "as my teachers are crappy".
    Any such sentiment only indicates a crappy kid with a very bad attitude.

  4. #4
    Registered User
    Join Date
    Apr 2010
    Posts
    25
    Quote Originally Posted by jwenting View Post
    stopped reading after "as my teachers are crappy".
    Any such sentiment only indicates a crappy kid with a very bad attitude.
    Don't talk too much, because your ignorance is greater than your knowledge.

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Wow this is hilarious.

    I have a new question here. I'll write it in this post.
    Guys, I have a problem. I need a program to solve TSP. Here's the code I have so far:
    Code:
    int main()
    {
    
    }
    Can somebody fill in the blanks?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Menu
    By Krush in forum C Programming
    Replies: 17
    Last Post: 09-01-2009, 02:34 AM
  2. Assignment Operator, Memory and Scope
    By SevenThunders in forum C++ Programming
    Replies: 47
    Last Post: 03-31-2008, 06:22 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Help with a pretty big C++ assignment
    By wakestudent988 in forum C++ Programming
    Replies: 1
    Last Post: 10-30-2006, 08:46 PM
  5. Replies: 1
    Last Post: 10-27-2006, 01:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21