/*Nurul Alis Alia Binti Mohamad Zamri Section 2
  Mirza Sabrina Binti Mohd Salmi*/

#include<iostream>
using namespace std;
int getCoin();
void calculateCoin( int &, int );

int getCoin()
{
	int coin;
	while(1)   //Input validation
	{
		cout<<"Enter the value of a coin: ";
		cin>>coin;
		if(coin<0)
		cout<<"The value cannot be less than zero!"<<endl;
		else 
		break;
	}
	
	return coin;
}

void calculateCoin( int &totalcoin, int coin)
{
	int num,total;
	while(1)  //input validation
	{
		cout<<"Enter the number of coins: ";
		cin>>num;
		if(num<0)
		cout<<"The number of coins cannot be less than zero!"<<endl;
		else 
		break;
	}

	total=num*coin;
	totalcoin+=total;
	cout<<"The total amount is "<<totalcoin<<endl<<endl;
}

int main()
{
	int total=0,price=120,balance;
	int coin;
	while(1)
	{
		coin=getCoin();
		calculateCoin(total,coin);
		if(total<price)
			cout<<"Insufficient amount!"<<endl;
		else
			break;
	}
	balance=total-price;
	cout<<"The balance amount is "<<balance<<endl;
	if(balance>0)
		cout<<"Please collect your balance."<<endl;
	else
		cout<<"TERIMA KASIH";
	return 0;
}
