0% found this document useful (0 votes)
40 views11 pages

Student - Assignment - Nov2022-1-1

The document contains instructions for an assignment with 5 questions. Question 1 asks to convert mathematical expressions to C++ arithmetic expressions. Question 2 asks to write a C++ program to determine voucher points based on average weekly purchases. Question 3 asks to write a C++ program to calculate the on-the-road price of car packages. Question 4 asks to write a C++ program to calculate membership charges based on package selected. Question 5 asks to write a C++ program to calculate tuition fees based on package and payment method selected.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views11 pages

Student - Assignment - Nov2022-1-1

The document contains instructions for an assignment with 5 questions. Question 1 asks to convert mathematical expressions to C++ arithmetic expressions. Question 2 asks to write a C++ program to determine voucher points based on average weekly purchases. Question 3 asks to write a C++ program to calculate the on-the-road price of car packages. Question 4 asks to write a C++ program to calculate membership charges based on package selected. Question 5 asks to write a C++ program to calculate tuition fees based on package and payment method selected.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

CSC126 – FUNDAMENTALS OF ALGORITHMS & COMPUTER PROBLEM SOLVING ASSESSMENT

#2: ASSIGNMENT

NAME Syahidatul Aqilah Mohd Supian : S: dd


STUDENT NO. 202261485 :
GROUP 6
D1CS1101C :

QUESTION 1

Convert the given mathematical expressions into its equivalent arithmetic expressions
in C++.

a) 𝐴 = 𝑎5 − 𝑏7

b) 𝑏
𝑠

c) 𝐸 = 2 𝑎−3𝑏 − 5(𝑑 − 12)2


𝑐−2

d) 𝐺 =

−𝑏+√𝑏2−4𝑎𝑐
e) 𝑥 =
2𝑎
(10 marks)

a) A = (pow(a,5) - pow(b,7));

b) b = sqrt (pow(a,2) + b - c) - (p - (4 * q)) / pow(s,3)

c) E = ((2 * a - 3 * b) / c - 2) - (5 * (pow (d - 12,2)));

d) G = 1 / (pow(x,2) + pow(y,2));

e) x = (-b + sqrt (pow(b,2) - 4 * a * c )) / (2 * a);

FaRMuN@UiTM Cawangan Kelantan Kampus Machang Page | 1


CSC126 – FUNDAMENTALS OF ALGORITHMS & COMPUTER PROBLEM SOLVING ASSESSMENT
#2: ASSIGNMENT

QUESTION 2

Chropter Sdn. Bhd. offers point rewards to customers based on the average of weekly
purchases for the past 4 weeks. Based on the calculated average weekly purchases
and several conditions, it then offers voucher points to its customers as shown in the
table given below:

Condition
Average weekly Purchases made Voucher Points
Successfully rated
Purchase from Preferred
a product
sellers
Less than 600 Y/N Y/N 0
More than or equal Y Y 300
to 600 and less than
1200
More than or equal Y Y/N 800
to 1200
Write a complete program in C++ which is capable of determining the voucher points
rewarded to the user and then display the customer ID, average weekly purchase and
the voucher points earned.
(10 marks)

FaRMuN@UiTM Cawangan Kelantan Kampus Machang Page | 2


CSC126 – FUNDAMENTALS OF ALGORITHMS & COMPUTER PROBLEM SOLVING ASSESSMENT
#2: ASSIGNMENT

#include <iostream>
using namespace std;
int main()
{
// if < 600 = 0 | 600 - 1200 = 300 | >= 1200 = 800 //
int averagePurchase, voucherPoints, id;
char productRated, preferredSellers;

cout << "\nCustomer ID : ";


cin >> id;
cout << "\nPlease enter average weekly purchase : ";
cin >> averagePurchase;
cout << "\nSuccesfully rated a product (y/n) :" << endl;
cin >> productRated;
cout << "\nPurchases made from preferred sellers (y/n) :" << endl;
cin >> preferredSellers;

if (averagePurchase < 600)


{
voucherPoints = 0;
}

else if ((averagePurchase >= 600) && (averagePurchase < 1200))


{
voucherPoints = 300;
}

else if (averagePurchase >= 1200)


{
voucherPoints = 800;
}

cout << "\nVoucher Points : " << voucherPoints;


return 0;
}

FaRMuN@UiTM Cawangan Kelantan Kampus Machang Page | 3


CSC126 – FUNDAMENTALS OF ALGORITHMS & COMPUTER PROBLEM SOLVING ASSESSMENT
#2: ASSIGNMENT

QUESTION 3

Proton Moon Sdn. Bhd. sells several packages of NEW X50 1.5 TGDI. Prices are as
illustrated in the following table:

Package Code Color Type Code Price (RM)


EX (for Executive) ME (for Metallic) 85,436.00
SM (for Special Metallic) 87,160.00
PR (for Premium) ME (for Metallic) 95,783.00 + additional price
SM (for Special Metallic) 97,131.00 + additional price

Write a complete C++ program segment to calculate and display the On-the-Road
(OTR) price based on the table given. If customers choose the Premium package, they
need to pay an additional price of RM3,500.00. Users can insert packages and color
types in capital letters or small letters.
(10 marks)

FaRMuN@UiTM Cawangan Kelantan Kampus Machang Page | 4


CSC126 – FUNDAMENTALS OF ALGORITHMS & COMPUTER PROBLEM SOLVING ASSESSMENT
#2: ASSIGNMENT

#include <string>
#include <iostream>
#include <cmath>
#include <math.h>
using namespace std;
int main()
{
string packageCode, colorType, ME, SM;
const int addPrice = 3500.00;
int price;

cout << "Choose package code (EX/PR)" << endl;


cin >> packageCode;
cout << "Coose color type code (ME/SM)" << endl;
cin >> colorType;

if (packageCode == "EX" || packageCode == "ex")


if(colorType == "ME" || colorType == "me")
price = 85436.00;

if(colorType == "SM" || colorType == "sm")


price = 87160.00;

if (packageCode == "PR" || packageCode == "pr")


if (colorType == "ME" || colorType == "me")
price = 95783.00 + addPrice;

if (colorType == "SM" || colorType == "SM")


price = 97131.00 + addPrice;

cout << "Amount to pay : " << price << endl;


return 0;
}

FaRMuN@UiTM Cawangan Kelantan Kampus Machang Page | 5


CSC126 – FUNDAMENTALS OF ALGORITHMS & COMPUTER PROBLEM SOLVING ASSESSMENT
#2: ASSIGNMENT

QUESTION 4

Write a complete program in C++ that calculates the charges for membership in a
SisKoM Club. The club has three membership packages to choose from: Institutional
Membership, Regular Membership and Student Membership. The program presents a
menu that allows the user to choose the desired package then calculates the cost of
the membership. The details of the packages are as follow:

Membership Package Code Membership Rate (RM)


Institutional Membership 1 50
Regular Membership 2 30
Student Membership 3 10

If the user enters an incorrect code for the membership package, display an error
message. Display the cost of the membership in TWO (2) decimal places.

Sample Output:

(10 marks)

FaRMuN@UiTM Cawangan Kelantan Kampus Machang Page | 6


CSC126 – FUNDAMENTALS OF ALGORITHMS & COMPUTER PROBLEM SOLVING ASSESSMENT
#2: ASSIGNMENT

#include <string>
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
cout << setw(65) << "WELCOME TO SISKOM MEMBERSHIP MENU";
cout << "\n1. Institutional Membership" << endl;
cout << "2. Regular Membership" << endl;
cout << "3. Student Membership" << endl;
cout << "4. Quit the program" << endl;
int package, code;
double rate, months, price;
cout << "/nEnter your choice : ";
cin >> package;
if (package == 4)
exit(1);
switch (package)
{
case 1:
code = 1;
rate = 50.00;
cout << "For how many months? ";
cin >> months;
cout << fixed << showpoint;
cout << "The total charges are RM " << setprecision(2) << (months * rate) <<
endl;
break;
case 2:
code = 2;
rate = 30.00;
cout << "For how many months? ";
cin >> months;
cout << fixed << showpoint;
cout << "The total charges are RM " << setprecision(2) << (months * rate) <<
endl;
break;
case 3:
code = 3;
rate = 10.00;
cout << "For how many months? ";
cin >> months;

FaRMuN@UiTM Cawangan Kelantan Kampus Machang Page | 7


CSC126 – FUNDAMENTALS OF ALGORITHMS & COMPUTER PROBLEM SOLVING ASSESSMENT
#2: ASSIGNMENT

cout << fixed << showpoint;


cout << "The total charges are RM " << setprecision(2) << (months * rate) <<
endl;
break;
default : cout << "Your code is invalid";
}
}

FaRMuN@UiTM Cawangan Kelantan Kampus Machang Page | 8


CSC126 – FUNDAMENTALS OF ALGORITHMS & COMPUTER PROBLEM SOLVING ASSESSMENT
#2: ASSIGNMENT

QUESTION 5

KAMI Tuition Center provides several packages on their services. Each student has to
pay RM70 for registration fee and notes. Each student is given a 20% discount if they
choose to make payment annually instead of monthly. The code for payment method
for annually and monthly is 1 and 2, respectively. The table indicates the packages
provided:

Package Type Number of subjects Fee per month (RM)


Starter 2 50
Star 3 80
Supreme 4 100
Super 5 110

Write a complete C ++ program to calculate and display the total fee for a year for
the selected package type and for the selected payment method either on a
monthly basis or a lump sum payment for a year.
(10 marks)

FaRMuN@UiTM Cawangan Kelantan Kampus Machang Page | 9


CSC126 – FUNDAMENTALS OF ALGORITHMS & COMPUTER PROBLEM SOLVING ASSESSMENT
#2: ASSIGNMENT

#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
cout << "\nWELCOME TO KAMI TUITION CENTER" << endl;
int subject, fee, sum;
char package;
int method;
// annuall x 0.2, monthly //

cout << "\nChoose your package :" << endl;


cout << "A .Starter" << endl << "B. Star" << endl << "C. Supreme" << endl << "D.
Super" << endl;
cout << "\nYou choose package ";
cin >> package;

cout << "\nChoose your method :" << endl;


cout << "1. Annual payment" << endl << "2. Monthly payment" << endl;
cout << "\nYou choose method ";
cin >> method;

switch (package)
{
case 'A':
fee = 50;
break;
case 'B':
fee = 80;
break;
case 'C':
fee = 100;
break;
case 'D':
fee = 110;
break;
}

switch (method)
{
case 1:
sum = ((fee * 12 + 70) * 0.8);

FaRMuN@UiTM Cawangan Kelantan Kampus Machang Page |


10
CSC126 – FUNDAMENTALS OF ALGORITHMS & COMPUTER PROBLEM SOLVING ASSESSMENT
#2: ASSIGNMENT

break;
case 2:
sum = ((fee * 12) + 70);
break;
}
cout << "\nTotal fee based on package type and payment method : " << sum <<
endl;
}

FaRMuN@UiTM Cawangan Kelantan Kampus Machang Page |


11

You might also like