#include <iostream>
using namespace std;

int main ()
{	
	int no_of_guests;
	int i=0,no_of_adult=0,no_of_children=0;
	int j=1,RoomID;
	int no_of_nights;
	double price_night;
	double total_payment,deposit,total_amount;

	//Ask user to input the number of guests
	cout << "Enter the number of guests : ";
	cin >> no_of_guests;

	//If user input the number of guests less than 0, the number of guests is invalid
	while (no_of_guests <= 0)
	{
		cout << "Number of guests entered is invalid."<< endl;
		cout << "Enter the number of guests again: ";
		cin >> no_of_guests;
	}
	
	//Loop selection for the age for guests' number
	while (i<no_of_guests) 
	{
		int age_of_guests[no_of_guests];

		//Ask user to input the age of guests
		cout << "Enter the age of guests " << (i+1) <<" : ";
		cin >> age_of_guests[i];

		//If the user input less than 0, the age is invalid
		if (age_of_guests[i] < 0)
		{
			cout << "Age is invalid.\n";
		}
		else 
		{
			if (age_of_guests[i] > 15)
				no_of_adult = no_of_adult+1;
			else 
				no_of_children = no_of_children+1;
			i=i+1;
		}
	}
	
	//while loop to allow user enters the room id
	while(j==1)
	{	
		j=j-1;

		//ask user to input the room ID
		cout << "Enter RoomID : ";
		cin >> RoomID;

		//If user input room id out of range, room id is invalid
		while (RoomID<1 || RoomID>5)
		{
			cout << "RoomID is invalid.\n";
			cout << "Enter RoomID : ";
			cin >> RoomID;
		}

		//If user select room ID 1	
		if (RoomID==1)
		{
			if (no_of_adult<=1 && no_of_children<=1)
				price_night = 300.00;
			else
			{
				cout << "Room reservation is not allowed because only 1 adult and 1 children is allowed.\n";
				j=j+1;
			}
		}

		//If user select room ID 2
		if (RoomID==2)
		{
			if (no_of_adult<=3 && no_of_children<=3)
				price_night = 510.00;
			else
			{
				cout << "Room reservation is not allowed because only max 3 adult and max 3 children is allowed.\n";
				j=j+1;
			}
		}

		//If user select room ID 3	
		if (RoomID==3)
		{
			if (no_of_adult<=2 && no_of_children<=3)
				price_night = 450.00;
			else
			{
				cout << "Room reservation is not allowed because only max 2 adults and max 3 children is allowed.\n";
				j=j+1;
			}
		}
		
		//If user select room ID 4
		if (RoomID==4)
		{
			if (no_of_adult<=1 && no_of_children<=2)
				price_night = 330.00;
			else
			{
				cout << "Room reservation is not allowed because only max 1 adult and max 2 children is allowed.\n";
				j=j+1;
			}
		}
		
		//If user select room ID 5
		if (RoomID==5)
		{
			if (no_of_adult<=4 && no_of_children<=5)
				price_night = 750.00;
			else
			{
				cout << "Room reservation is not allowed because only max 4 adult and max 5 children is allowed.\n";
				j=j+1;
			}
		}
	}
	
	//Ask user to input the number of nights
	cout << "Enter the number of nights : ";
	cin >> no_of_nights;

	//If the number of nights is less than 0, the input is invalid
	while(no_of_nights<0)
	{
		cout << "Number of nights entered is invalid.\n";
		cout << "Enter the number of nights : ";
		cin >> no_of_nights;
	}
	
	//Calculate the total price, deposit based on the number of guests and the total amount
	total_payment = price_night*no_of_nights;
	deposit = 100*no_of_guests*no_of_nights;
	total_amount = total_payment + total_payment*0.06 + deposit;

	//Display the total amount of room payment
	cout << "The total amount of room payment " << RoomID << " is : RM " << total_amount;
	
	return 0;
}
