Please write the coding clearly.I need to understand how to solve this question.
ID: 3875423 • Letter: P
Question
Please write the coding clearly.I need to understand how to solve this question.
PART C (30 MARKS) QUESTION 1 UITM Melaka will organize a programming contest among students from schools and local universities in Malaysia. The organizer would like to develop a program to calculate the fee for the contest. If the participants are from UiTM, 10% discount will be given to them. Below are the fee rates for the contest Contest Level School (S) Easy (E) Intermediate () 25.00150.00 Advanced(A) 40.00 Fee(RM) /per person 20.00 40.00 250.00 University (U) e a complete C++ program that will be repeated until the user enter 'N' to stop. The program will perform the following tasks: a) Prompt the user to input the following information: Contest level (E-Easy l-Intermediate or A-Advanced) Category (S-School or U-University) The name of the school or university The number of participants Calculate thetotal fee for each school or university The total fee is subjected to 6% Government Service Tax. c) Display the receipt as shown in the following example: Receipt PROGRAMMING CONTEST UiTM MELAKA Name of school/university: UiTM Contest level: Advance Number of participants :2 Fee : RM 500.00 GST: RM30.00 Discount: RM50.00 Total Fee : RM480.00 (15 marks) Hak Cipta Universiti Teknologi MARA CONFIDENTIALExplanation / Answer
#include <iostream>
#include <string>
using namespace std;
void displayReceipt(char level, char category, string name, int participants) {
float fee, gst, discount = 0, total;
string levelName;
if (category == 'S') {
if (level == 'E') {
levelName = "Easy";
fee = 20.00 * participants;
} else if (level == 'I') {
levelName = "Intermediate";
fee = 25.00 * participants;
} else {
levelName = "Advanced";
fee = 40.00 * participants;
}
} else {
if (level == 'E') {
levelName = "Easy";
fee = 40.00 * participants;
} else if (level == 'I') {
levelName = "Intermediate";
fee = 150.00 * participants;
} else {
levelName = "Advanced";
fee = 250.00 * participants;
}
}
gst = fee * 6 / 100;
if (name.compare("UiTM") == 0) {
discount = fee / 10;
}
total = fee + gst - discount;
cout<<" Receipt ";
cout<<" PROGRAMMING CONTEST UiTM MELAKA ";
cout<<" Name of school or university : "<<name<<" ";
cout<<" Contest level : "<<levelName<<" ";
cout<<" Number of participants : "<<participants<<" ";
cout<< " ";
cout<< " Fee : RM "<<fee<<" ";
cout<< " GST : RM "<<gst<<" ";
cout<< " Discount : RM "<<discount<<" ";
cout<< " Total Fee : RM "<<total<<" ";
}
int main()
{
char opt;
char level;
char category;
string name;
int participants;
bool flag = true;
while(flag) {
cout<<"Please give input:-";
cout<<"Contest level(E-Easy, I-Intermediate or A-Advanced) : ";
cin>> level;
cout<<"Category(S-School or U-University) : ";
cin>> category;
cout<<"Name of school or university : ";
//std::getline (std::cin,name);
cin>> name;
cout<<"The number of participants : ";
cin>> participants;
displayReceipt(level, category, name, participants);
cout<<"Press N to exit or Y to countinue";
cin >> opt;
if (opt == 'N' || opt == 'n') {
flag = false;
}
}
return 0;
}