/* Assignment 2: SECJ 1013 Section 8
------------------------------------------------------------
Group 5: - Teh Jing Ling (A20EC0228)
		    - Eunice Lim Xian Ni (A20EC0034)
		    - Wong Hui Shi (A20EC0169)
Title: Calculation on Airplane Ticket (case study 3) 
------------------------------------------------------------ */

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main ()
{
	
	int year, month, date, choice, price;
	char day;
	/* ---------------------------------------------------------------------------------------------
	   Purpose: To display all the destinations, dates and years so that user knows what choice to pick.
	   User is required to enter Departure Date according to the format:  - Day : (Monday to Sunday)
	                          							    		      - Year: (2020-2022) 
	                         									     	  - Month: (1-12) 
	                          											  - Date(1-28,30,31).
	   Any value out of range is INVALID. 
	 -----------------------------------------------------------------------------------------------  */
	cout << "Please fill in the departure date. \n";
	cout << "M = Monday\n" << "T = Tuesday\n" 
	<< "W = Wednesday\n" << "H = Thursday\n" << "F = Friday\n"
	<< "S = Saturday\n" << "U = Sunday\n";
	cout << "\nPlease fill in the year between 2020 and 2022, inclusive.\n\n";
	
	// To receive departure day from user.
	cout << "Day: ";
	cin >> day;

	while ((day=='M')||(day=='T')||(day=='W')||(day=='H')||(day=='F')||(day=='S')||(day=='U'))
    {
    	cout << "Enter year : " ;
	    cin >> year;
	    // Program will immediately stop if user did not enter according
	    // to the displayed format.
		break;
	}	

	if((year>=2020)&&(year<=2022))
	{
		// Receive departure month from user.
		cout << "Enter month : ";
		cin >> month;
    
      if((month>=1)&&(month<=12))
	  {
	  	// Receive departure date from user.
			cout << "Enter date : ";
			cin >> date;
			
	    if((date>=1)&&(date<=31)&&(date!=29))
		{		
			// If the date is less than one week from 5th November 2020, then the price will be double.
			if(((date<=11)&&(date>=5))&&(year==2020)&&(month==11))
			{
				cout << "\nBandar Seri Begawan = 1 \n" << "Manila = 2 \n" << "Phnom Penh = 3 \n"
					<< "Siem Reap = 4 \n" << "Hanoi = 5 \n\n" << "Please enter a destination: " ;
					cout << "\n";
			     cout << "Enter choice : ";
			     cin >> choice;
			     
			     switch (choice)
		         {
		             case 1 : price=2*1499;
		                      cout << "The price is " << price;
		                      break;
		             case 2 : price=2*1899;
		                      cout << "The price is " << price;
		                      break;
		             case 3 : price=2*2099;
		                      cout << "The price is " << price;
		                      break;
		             case 4 : price=2*1909;
		                      cout << "The price is " << price;
		                      break;
		             case 5 : price=2*1129;
		                      cout << "The price is " << price;
		                      break;
		             default : cout << "INVALID";
		                      break;
		         }
			}
			else
			{
				// If the date is NOT less than one week from 5th November 2020, then it will be normal price.
				cout << "\nBandar Seri Begawan = 1 \n" << "Manila = 2 \n" << "Phnom Penh = 3 \n"
				<< "Siem Reap = 4 \n" << "Hanoi = 5 \n\n" << "Please enter a destination: " ;
				cout << "\n";
		   		cout << "Enter choice : ";
				cin >> choice;
				switch (choice)
		 		{
		   		   case 1 : price=1499;
		       		        cout << "The price is " << price;
		           		    break;
			   	   case 2 : price=1899;
		         		    cout << "The price is " << price;
		               		break;
		       	   case 3 : price=2099;
		           		    cout << "The price is " << price;
		               		break;
		       	   case 4 : price=1909;
		           		    cout << "The price is " << price;
		               		break;
		     	   case 5 : price=1129;
		       		        cout << "The price is " << price;
		           		    break;
		       	   default : cout << "INVALID";
		           		     break;
		  	 	}
		  	}	  	
		}
		else
		{
			cout << "INVALID";
		}
	}
	else
	{
		cout << "INVALID";
	}
    }
	return 0;
}
