Professional Documents
Culture Documents
Ec1102n - Mimi Nur Nabila Binti Alias - 2019293128 - Final Exam
Ec1102n - Mimi Nur Nabila Binti Alias - 2019293128 - Final Exam
INSTRUCTIONS TO CANDIDATES:
2. Answer ALL questions in this file. Start each answer on a new page.
STUDENT ID : 2019293128
GROUP : EC1102N
PART A
QUESTION 1
Create a flowchart that calculates a Health Screening charge for a patient. Your flowchart
should prompt the user to enter patient’s category ( A – adult / C – children / S – senior citizen).
Display “Error: Invalid Patient Category” if the user enters a wrong input. Then the flowchart
will calculate and display the total charge. An additional charge of RM50.00 will be incurred if
the user selected 1-hour rapid test result. The total charge is determined by the following Table
1.1.
A RM 148.00 + RM 50.00
(5 marks)
Start
Get category
Get rapidTest
If ( category == ‘A’ )
&& ( rapidTest == ‘Y’ )
Yes
Payment = 148 + 50 No
Else if ( category ==
‘C’ || ‘S’ ) && (
rapidTest == ‘Y’ )
Yes
Payment = 110 +50 No
Else if ( category ==
‘A’) && ( rapidTest !=
‘Y’ )
Yes
No
Payment = 148
Else if ( category
== ‘C’ || ‘S’ ) && (
rapidTest != ‘Y’ )
Yes
Payment = 110 No
Else
End
QUESTION 2
UiTM will organize an eating competition. Points will be given based on the food weight as
shown in Table 2.1 below:
Write the program segment where the weight and age will be entered by the participant.
Then display the participant’s score. The calculation of the score is based on following
formula.
(5 marks)
#include<iostream>
int main()
cin>>weight;
cout<<”Enter age: “;
cin>>age;
if ( weight <100 )
if ( age <= 12 )
score = 2 * weight;
score = 1 * weight;
if ( age <= 12 )
score = 3 * weight;
score = 2 * weight;
return 0;
QUESTION 3
Subway requested to develop a program that can take orders using self-order machine for
those who wants to buy their sandwiches of the day.
You are required to write a code segment that will ask the customer, how many sets are they
ordering. By using for loop, your program will be repeated based on the number of sets that
they’ve entered. For each iteration, the program should ask the user to choose the side dish
type either [1- Chips] or [2-Cookies] to make it a meal set. Count the number of chips and
cookies that had been chosen.
Then the program will display total number of chips and cookies and total price in two decimal
places as in Figure 3.1 below where the price for each set is RM10.90.
(5 marks)
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double total;
int meal, sides;
int calcChips=0, calcCookies=0;
cout<<"Number of meal sets: ";
cin>>meal;
for(int i=1; i<=meal; i++)
{
QUESTION 4
Display the lowest odd number among ten positive integer numbers between 1 to 100
entered by the user. Given is the sample output screen:
1) 78
2) 65
3) 22
4) 56
5) 99
6) 2
7) 3
8) 15
9) 73
10) 85
(5 marks)
#include<iostream>
int main()
int num, n = 1, i = 0;
while ( i < 10 )
cout<<n++<<") ";
cin>>num;
i++;
if ( num % 2 != 0 )
minimum = num;
return 0;
QUESTION 5
Johor Taekwondo Club is organizing Johor Open Taekwondo Championship. The following
Table 5.1 shows the details of the championship:
As a programmer hired by the club, you are required to write a C++ program for the
championship registration system based on the following tasks:
The sample input and output of the program shown as below (The shaded texts are the inputs
for the system) :
-----------------------------------------------------
JOHOR OPEN TAEKWONDO CHAMPIONSHIP REGISTRATION SYSTEM
-----------------------------------------------------
-----------PARTICIPANT'S SLIP------------
Name : MOHD ARIS BIN MOHD ABU
Discipline : Kyorugi
Category : Junior
Fee : RM50
-----------------------------------------
-----------PARTICIPANT'S SLIP------------
Name : KALAI A/L MUTHU
Discipline : Invalid Code!!
Category : N/A
Fee : RM0
-----------------------------------------
-----------PARTICIPANT'S SLIP------------
Name : KALAI A/L MUTHU
Discipline : Kyorugi
Category : Senior
Fee : RM60
-----------------------------------------
-----------PARTICIPANT'S SLIP------------
Name : CHERYL TAN
Discipline : Poomsae
Category : Junior
Fee : RM55
-----------------------------------------
-----------PARTICIPANT'S SLIP------------
Name : SITI AISHAH BINTI AHMAD
Discipline : Kyorugi
Category : Invalid age!!
Fee : RM0
-----------------------------------------
(20 marks)
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
char choice;
string team;
double total, discountFee, totalFee;
double totalKyorugi = 0, totalPoomsae = 0;
cout<<"-----------------------------------------------------"<<endl;
cout<<"JOHOR OPEN TAEKWONDO CHAMPIONSHIP
REGISTRATION SYSTEM"<<endl;
cout<<"-----------------------------------------------------"<<endl;
cout<<"\nTeam Name: ";
getline(cin,team);
cout<<endl;
total = participant(totalKyorugi, totalPoomsae);
cout<<endl;
cout<<"Is your team registered under Johor Taekwondo
Club? <Y|N>: ";
cin>>choice;
discountFee = discount(choice, total);
totalFee = total - discountFee;
cout<<endl;
cout<<"******EXCELLENT TAEKWONDO CLUB
REGISTRATION SLIP*******"<<endl<<endl;
cout<<"Total Kyorugi Fee :
RM"<<setprecision(2)<<totalKyorugi<<endl;
cout<<"Total Poomsae Fee :
RM"<<totalPoomsae<<endl;
cout<<"Discount Fee :
RM"<<discountFee<<endl;
cout<<"Total Fee (Before Discount): RM"<<total<<endl;
cout<<"Total Fee (After Discount) :
RM"<<totalFee<<endl;
}
double participant(double totalKyorugi, double totalPoomsae)
{
char code, choice;
string name, discipline, category;
discipline = "Poomsae";
if (age >= 12 && age <= 14)
{
category = "Cadet";
fee = 45;
}
else if (age >= 15 && age <= 17)
{
category = "Junior";
fee = 55;
}
else
{
cout<<"Invalid age!!"<<endl;
break;
}
totalPoomsae = totalPoomsae + fee;
}
else
{
cout<<"----------PARTICIPANT'S SLIP----------"<<endl;
cout<<"Name :"<<name<<endl;
cout<<"Discipline : Invalid Code!!"<<endl;
cout<<"Category : N/A"<<endl;
cout<< "Fee : RM0"<<endl;
cout<< "--------------------------------------"<<endl;
break;
}
cout<< "\n----------PARTICIPANT'S SLIP----------
"<<endl;
cout<< "Name :"<<name<<endl;
cout<< "Discipline :"<<discipline<<endl;
END OF QUESTIONS