#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

int main()
{
	int code[15][2]={0};
	int Tnumber, food[3]={3314,2220, 1118}, number[3]={0,0,0};
	int n1, n2;
	double Amount, price, discount, GST, total[15]={0}, sales;
	ifstream inp("input2.txt");
	ofstream out("output.txt");
	
	if(!inp.is_open())
	{
		cout << "Error!!!" << endl;
		exit(0);
	}
	out << fixed <<setprecision(2);
	
	out << setw(54) << "Dynamic Restaurant's Weekly Sales Report" << endl << endl;
	out << "::SALES DETAILS::" << endl;
	out <<"========================================================================"<< endl;
	out <<"Code   Quantity   Price(RM)   Amount(RM)   Discount(%)   GST   Total(RM)" << endl;
	out <<"========================================================================"<< endl;
		
	int i=0;
	while(inp >> n1)
	{
		if(n1==0)
		break;
		
		inp>>n2;
		code[i][0]=n1;
		out << code[i][0];
		
		code[i][1]=n2;
		out <<setw(11)<< code[i][1];		
		
		switch(code[i][0])
		{
			case 3314:price=14.00;
					  Amount=price*n2;
					  GST=0.00;
					  number[0]+=n2;
				      break;
			case 2220:price=20.00;
					  Amount=price*n2;
					  GST=6.00;
					  number[1]+=n2;
				      break;
			default:price=18.00;
					Amount=price*n2;
					GST=6.00;
					number[2]+=n2;
				    break;
		}
		if(n2>=15)
		discount=5.00;
		else
		discount=0.00;
		
		total[i]= Amount*(1-discount/100)*(1+GST/100);
		sales+=total[i];
		
		out << right;
		out <<setw(11)<< price <<setw(14)<< Amount <<setw(14)<< discount <<setw(7)<< GST <<setw(11) <<total[i] << endl;
		i++;
	}
	out <<"========================================================================\n"<< endl;
	out <<"::SALES STATISTICS::"<< endl;
	out <<"========================================================================"<< endl;
	out << setw(10) << "Code" << setw(30) <<" Total Quantity" << endl;
	out <<"========================================================================"<< endl;
	for(int r=2;r>=0;r--)
	{
		out << setw(10)<< food[r] <<  setw(30) << number[r] << endl;;
	}
	out <<"========================================================================\n"<< endl;
	out <<"Total Sales = RM "<<sales<<endl;
	
	out.close();
	inp.close();
	
	return 0;
}
