I am new to programming and i am teaching myself. (my teachers are not very good)
I am attempting an old assignment that a colleage had completed in school.
He told me it was pretty basic in terms of c++ programming.

UELS is a company selling bicycles;
Customers may opt to buy more than one bicycle as long as it is the same model.
If other models are also required then a separate transaction must be made.
The sales process is decided to be automated.
I have to implement and test a sales program.


The first task is to produce a menu (see below):

1. display company logo
2. input/validate weekly sales data
3. calculate weekly sales
4. display reciept
5. exit

I am attempting the options part by part.
i attempted the first part, but it didn't compile

CAN anyone help ?

I'd be extremely appreciative of any hints and help

(my code)

#include <iostream.h>
main()
	{
   	int number;

      	cout << "1. Display Company Logo.";
      	cout << "2. Input/Validate weekly sales data.";
      	cout << "3. Calculate weekly sales.";
      	cout << "4. Display reciept.";
      	cout << "5. Exit.";

         cout << "\nEnter number...\n";
         cin >> number;

      switch (number)
      	{
      		case [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\t\LL\t\t       S";
                    "\n\tUU\tUU  \tEE  \t  \t\LL  \t\t       S ";
                    "\n\t UUUUUUUU   *\tEEEEEEEE  *\tLLLLLLL  *\tSSSSSSS   *";break;
            default:cout<<("No such group");
         }
      getch();
   }

My pro

Edited 6 Years Ago by WaltP: Added CODE Tags

First use Code Tags;
Second it's case 1: not case [1]:

I'll provide a Switch Code for u to See

#include <iostream>

using namespace std;

int main()
{
        int opt;

        cout << "1. Hello!" << endl;
        cout << "2. Bye!" << endl;
        cin >> opt;

        switch(opt)
        {
        case 1:
                cout << "Hello!" << endl;
                break;
        case 2:
                cout << "Bye!" << endl;
                break;
        default:
                cout << "Input Error.." << endl;
                break;
        }

        return 0;
}

Enjoy :)

part 1 was to display a suitable text-based logo for the company.
part 2 was to input data from the keyboard:
salesman code (integer 1-20)
bike price
model code
quantity sold
date

Validate each data item; if an error is detected display an appropriate message and allow the user to re-type the data

I think i did the first part is ok, but i have no idea how to validate the date.

#include <iostream.h>

#include <conio.h>
main()
	{
   	int number;
      cout << "******Sales System******";
      do
      	{
            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");

      		switch (number)
      			{
      				case 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:

            			cout << ("Input/validate weekly sales data"); 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:

            			cout << ("Enter a number from 1-5 only!");

         		}
      	} while (number !=5);
      getch();
   }

how would i incorporate the second part of the program in to the first (within case 2) and run it successfully ?
here is the second part

/*****second part****/

#include <conio.h>

#include <iostream.h>

main()

{
   //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 << "\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 << "\nPlease enter the date ";
      	cin >> date;

        	cout << ("\n");

   getch();
}

Much appreciated

take that second piece of code you have and turn it into a function in the first piece of code you posted. like this:

#include <iostream.h>

#include <conio.h>

void WeeklySales();

main()
	{
   	int number;
      cout << "******Sales System******";
      do
      	{
            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");

      		switch (number)
      			{
      				case 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:

            			cout << ("Input/validate weekly sales data"); 
                                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:

            			cout << ("Enter a number from 1-5 only!");

         		}
      	} while (number !=5);
      getch();
   }

void WeeklySales()
{
//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 << "\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 << "\nPlease enter the date ";
      	cin >> date;

        	cout << ("\n");
}

Edited 6 Years Ago by NathanOliver: n/a

This article has been dead for over six months. Start a new discussion instead.