weddingplanner

mail@pastecode.io avatar
unknown
c_cpp
a year ago
9.3 kB
1
Indexable
Never
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>

using namespace std;


const int people_per_coke_case= 6;
const int people_per_water_case= 2;
const int cost_coke= 30;
const int cost_water= 20;

int guests, cards, sweets, tables, coke, water, card_price, coke_price, water_price;

void choice( &menyChoice, int &guests);
void menyChoice ();
void guests_invited(int &guests);
void card_sweets(int &guests,int &cards,int &sweets);
void tables_reserved(int &guests,int &tables);
void drinks(int &guests, int &coke, int &water, const int &people_per_coke_case, const int people_per_water_case);
void card_cost(int &guests,int &card,int &card_price);
void drink_cost(int &coke, int &water, const int &cost_coke, const int &cost_water, int &coke_price, int &water_price);
void display(int &guests, int &cards, int &sweets, int &tables, int &coke, int &water, int &card_price, int &coke_price, int &water_price);


int main()
{
      bool repeat = true;

     while (repeat== true){

     int menyChoice;

     cout << " Hello , Wedding Planning Assistant is pleased to be at your service!\n"<< endl << endl;

     cout << " 1. Enter number of invited guests.\n" <<endl;
     cout << " 2. Determine the number of invitation cards and sweets.\n "<< endl;
     cout << " 3. Determine the number of tables needed.\n " << endl;
     cout << " 4. Determine drinks order.\n "<< endl;
     cout << " 5. Cost of invitation cards \n"<< endl;
     cout << " 6. Cost of drinks\n" << endl;
     cout << " 7. Display all information\n " << endl;
     cout << " 8. Quit\n" << endl;
     cin >> menyChoice;



     //menu
     switch (menyChoice)
     {
        case 1: guests_invited (guests) ;
            break;
        case 2:card_sweets(guests, cards, sweets);
            break;
        case 3:tables_reserved(guests, tables);
            break;
        case 4:drinks(guests,coke,water,people_per_coke_case,people_per_water_case);
            break;
        case 5:card_cost(guests, cards, card_price);
            break;
        case 6:drink_cost(coke,water,cost_coke,cost_water,coke_price,water_price);
            break;
        case 7:display (guests,cards,sweets, tables, coke, water, coke_price, water_price, card_price);
            break;
        case 8:
            repeat =false;

     }

     return 0;
     }
}




void choice (&menyChoice, int &guests)
{
    while (guests < 1)
    {


    if ((menyChoice >= 1) and (menyChoice <=8 ))
		{
			cout << "You choose option "<< meny_valg<<"."<<endl;
		}
		else
		{
			cout << "INVALID INPUT!"<<endl;
			cin >> meny_valg;
			}
break;

    }

}
void guests_invited (int &guests)
{
cout << "How many quests do You want to invite? \nNumber of invited guests: "<<endl;
	cin >> guests;
	cout<<"You choose to invite "<< guests << " quests at your weeding!"<<endl<<endl;

return;

}



void card_sweets (int &guests, int &cards ,int &sweets)
{
    if (guests==0 )
       {

        cout << "please decide how many people are invited first,  choose  option 1";
        return;
       }
    else
        {
            guests= guests;
            cards = guests /2;
            sweets = guests *1.2;
        cout <<"Number of invitation cards needed for "<<guests<<" guests: "<<cards<<"."<<endl
		<<"Number of sweets needed for "<<guests<<" guests: "<<sweets<<"."<<endl;
            return;
        }
}


void tables_reserved (int &guests, int &tables)
{
   if (guests ==0)
  {
  cout <<"please choose option 1 first";
  return;
  }
  else if (guests%6==0)
  {


  tables=guests/6;
  return;
  }
else
{


   tables = guests/6+1;
   return;
  }



}

void drinks (int &guests, int &coke, int &water, const int &people_per_coke_case, const int &people_per_water_case) // calculates number of drinks needed. Again, overvrites ## globally
{
	if (guests == 0)
	{
		cout
		<<"------------------------------------------------------------------------------------------------------"<<endl
		<<"You haven't choose how many people will be invited! \nGo back to 'MENU' and choose '1', please."<<endl
		<<"------------------------------------------------------------------------------------------------------"<<endl;
		return;
	}
	else
	{
		int temp_coke;
		int temp_water;
		temp_coke = guests / people_per_coke_case;
		temp_water = guests / people_per_water_case;
		coke = floor(temp_coke);
		water = ceil(temp_water);
		cout
		<<"------------------------------------------------------------------------------------------------------"<<endl
		<<"You will need: "<<coke<<" boxes of coke for "<<guests<<" guests."<<endl
		<<"You will need: "<<water<<" boxes of water for "<<guests<<" guests."<<endl
		<<"------------------------------------------------------------------------------------------------------"<<endl;
		return;
	}
}

void card_cost (int &cards,int &guests, int &card_price) // Same as the others ;)
{
	if ((guests == 0) || (cards == 0))
	{
		cout << "You haven't choose how many people will be invited or how many invitation cards You will need! \nGo back to 'MENU', please."<<endl;
		return;
	}
	else
	{
		card_price = cards*200;
		cout
		<<"------------------------------------------------------------------------------------------------------"<<endl
		<<cards<<" invitation cards for "<<guests<<" guests will cost: "<<card_price<<" NOK."<<endl
		<<"------------------------------------------------------------------------------------------------------"<<endl;
		return;
	}
}
void drink_cost(int &coke, int &water, const int &cost_coke, const int &cost_water, int &coke_price, int &water_price) // Same as the others ;)
{
	if ((guests == 0) || ((coke == 0) && (water = 0))) // "water = 0" CONDITION IS MAYBE USELESS HERE ?
	{
		cout
		<<"------------------------------------------------------------------------------------------------------"<<endl
		<< "You haven't choose how many people will be invited or how many cases of each drink You will need! \nGo back to 'MENU', please."<<endl
		<<"------------------------------------------------------------------------------------------------------"<<endl;
		return;
	}
	else
	{
		cout<<coke<<endl;
		cout<<water<<endl;
		coke = coke;
		water = water;
		coke_price = coke * cost_coke;
		water_price = water * cost_water;
		cout
		<<"------------------------------------------------------------------------------------------------------"<<endl
		<<"Cost of coke for the wedding will be: "<<coke_price<<" NOK."<<endl
		<<"Cost of water for the wedding will be: "<<water_price<<" NOK."<<endl
		<<"Total cost of drinks will be: "<<coke_price+water_price<<" NOK."<<endl
		<<"------------------------------------------------------------------------------------------------------"<<endl;
		return;
	}
}
void display (int &guests, int &cards, int &sweets, int &tables, int &coke, int &water, int &coke_price, int &water_price, int &card_price) // cout ONLY
{
	if (guests == 0)
	{
		cout << "You need to put inn number of guests invited first\n "<<
		"Go back to 'MENU' and choose '1', please."<<endl;
		return;
	}
	else
	{
		cout <<"------------------------------------------------------------------------------------------------------"<<endl;

		cout<<"the number of guests invited to this wedding: "<< guests <<endl;			// GUESTS
		((tables == 0)?														// TABLES
		(cout<<"You haven't calculated number of tables needed yet!'"<<endl):
		(cout<<"For "<< guests << "guests we need:"<<tables <<"tables."<<endl));

		cout <<"------------------------------------------------------------------------------------------------------"<<endl;

		((cards == 0)?														// CARDS
		(cout<<"You haven't calculated number of invitation cards needed yet!'"<<endl):
		(cout<<"Numer of cards needed "<<cards<<"."<<endl<<"Total cost of invitation cards: "<<card_price<<" NOK."<<endl));

		((sweets == 0)?														// SWEETS
		(cout<<"You haven't calculated number of sweets needed yet!'"<<endl):
		(cout<<"Numer of sweets needed "<<sweets<<"."<<endl));

		cout <<"------------------------------------------------------------------------------------------------------"<<endl;

		((coke == 0)?														// DRINKS
		(cout<<"You haven't calculated number of cases of coke needed yet!'"<<endl):
		(cout<<"Numer of cases of coke needed "<<coke<<"."<<endl<<"Total cost of coke for the weeding: "<<coke_price<<" NOK."<<endl));

		((water == 0)?
		(cout<<"You haven't calculated number of cases of water needed yet!'"<<endl):
		(cout<<"Numer of cases of water needed "<<water<<"."<<endl<<"Total cost of water for the weeding: "<<water_price<<" NOK."<<endl));

		cout<<"Total cost of drinks for the wedding: "<< coke_price + water_price <<"."<<endl;

		cout <<"------------------------------------------------------------------------------------------------------"<<endl;

		cout<<"Total cost for the weeding: "<< card_price+coke_price+water_price<<"NOK."<<endl;		// TOTAL COST

		cout <<"------------------------------------------------------------------------------------------------------"<<endl;
	}
}