0% found this document useful (0 votes)
160 views9 pages

(CSC415) Final Assessment July 2022

The document contains instructions for a final assessment exam consisting of two parts with multiple choice and written answer questions. The exam covers topics related to fundamentals of computer problem solving including arrays, functions, loops, and file input/output. The exam is divided into two parts and includes questions related to pre-test and post-test loops, arrays, functions, file processing, and calculating totals from data files.

Uploaded by

zuewa
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)
160 views9 pages

(CSC415) Final Assessment July 2022

The document contains instructions for a final assessment exam consisting of two parts with multiple choice and written answer questions. The exam covers topics related to fundamentals of computer problem solving including arrays, functions, loops, and file input/output. The exam is divided into two parts and includes questions related to pre-test and post-test loops, arrays, functions, file processing, and calculating totals from data files.

Uploaded by

zuewa
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/ 9

CONFIDENTIAL 1 CS/JUL 2022/CSC415

UNIVERSITI TEKNOLOGI MARA


FINAL ASSESSMENT

COURSE : FUNDAMENTALS OF COMPUTER PROBLEM


SOLVING
COURSE CODE : CSC415
EXAMINATION : JULY 2022
TIME : 3 HOURS

INSTRUCTIONS TO CANDIDATES

1. This question paper consists of two (2) parts: PART A (4 Questions)


PART B (2 Questions)

2. Answer ALL questions in the Answer Sheet.

3. Answer ALL questions in English.

4. Please submit typewritten / handwritten answer in PDF format.

5. Name your file in this format: groupname_yourname.pdf. For example: N4CS2481A_Aminah


Hassan.pdf

DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO


This examination paper consists of 9 printed pages

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 2 CS/JUL 2022/CSC415

PART A (60 MARKS)

QUESTION 1 (15 marks)

a. Explain the difference of Pre-Test and Post-Test repetition control structures. Give ONE
example for each.
(5 marks)

b. Show the output of the following program segment. Then, rewrite the program segment
by using the while loop structure.

int main()
{ int x = 5;
for (int a = x; a > 0; a--)
cout << a * 5 << “ “;
return 0;
}

(5 marks)

c. Eric opened the savings account at PC Bank in January 2022 with the first savings is RM
10,000. If the yearly interest is 10%, in what year the total savings in the account will be
exceeding RM 1 million. Write a program segment to calculate and display the year and
the total savings.
(5 marks)

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 3 CS/JUL 2022/CSC415

QUESTION 2 (15 marks)

a. Assuming an array named Player_ID and Point are initialized as shown in Figure 2.

Player_ID 101 102 103 104 105 106

Point 55.2 70.7 65.5 88.9 35.6 22.5

Figure 2

i) Declare one-dimensional arrays to store Player_ID data. Player_ID array is an


integer-type array. Initialize all elements to the respective arrays.
(2 marks)

ii) Declare one-dimensional arrays to store Point data. Point array is a floating-type
array. Initialize all elements to the respective arrays.
(3 marks)

b. Find and display:

i) The number of players who get points more than 50.


(3 marks)

ii) The highest point together with the Player_ID who gets the highest point.

(7 marks)

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 4 CS/JUL 2022/CSC415

QUESTION 3 (15 marks)

a. Given the code fragment.

int main()
{
float taxRate = 0.06;
float price, taxAmt;
char type;

cout << “Enter product’s price : ”;


cin >> price;
cout << “Enter product’s price : ”;
cin >> type;

taxAmt = calcTax(price, taxRate, type)

cout << “The gst amount is ” << taxAmt << endl;

return 0;
}

Based on the code fragment, write the function prototype to declare function
calcTax(). Then, write the complete definition for function calcTax(). This function
calculates the amount of goods and service tax, then returns the tax amount to caller
function.

Tax is imposed on all types of products except product with type ‘F’. If the product code
is ‘F’, the tax amount is zero.

The tax amount is calculated using the following formula:

Tax amount = price * tax rate


(6 marks)

b. Write the functions definitions for function OddEven() that takes one argument of type
integer. The function returns the character value ‘O’ if its argument is an odd number and
returns ‘E’ if its argument is an even number.
(4 marks)

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 5 CS/JUL 2022/CSC415

c. Determine the output of the following code.

#include <iostream>
using namespace std;

void MyFunc (int& m)


{
int n=2;
if (m % 2 == 0)
{
n++;
m=m+5;
}
else
{
n--;
m=m+3;
}
cout << m << ", " << n << endl;
}
int main()
{
int num=9;
for (int counter = 0; counter < 5; counter++)
{
num=num+counter;
MyFunc (num);
}
return 0;
}

(5 marks)

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 6 CS/JUL 2022/CSC415

QUESTION 4 (15 marks)

a) bookBorrower.txt file consists of borrowers’ information who borrow the book


from Seremban Public Library. The information is comprised myCard id, name, book
category, number of books and number of overdue days. Assume that each student
will borrow only one category of books.

Write a C++ statement for each of the following tasks:


i) Declare inFile as an input stream variable and outFiles as output
stream variable. Associate the file stream variable with the input and output
sources. The file for input is bookBorrower.txt and the output file is
overPayment.txt
(3 marks)

ii) Based on bookBorrowers.txt, read the input data calculate the penalty
payment that should be paid by each borrower. The rate of overdue penalty
for each book is based on book category as shown in the following table

Type of book Penalty Rate Per Day (RM)


Children 1.50
Novel 2.00
Fiction 2.50
Reference 3.00

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 7 CS/JUL 2022/CSC415

Then, calculate the total payment from all students. The output for overpayment
is as follows :

(6 marks)

b) The program read data from drinks.txt, which consists of the list of drinks and

sales per day as shown:

Coffee152
Tea 120
Juice 335
Espresso 113

Write C++ statements to read all data from drinks.txt and display the total sales
for all the drinks.
(6 marks)

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 8 CS/JUL 2022/CSC415

PART B (40 MARKS)

QUESTION 1

FGH Healthcare Sdn Bhd is a COVID-19 Antigen Test Kit whole seller in Kuala Lumpur. The
management wants to develop a simple program to help its distributors to calculate the
wholesale price. The table below depicts the details of the products offered.

Product Code Quantity Wholesale Price Minimum


(RM) Order
AT 10-50 pcs 4.00 10
51-100 pcs 3.00
More than 100 pcs 2.50
GM 20-50 pcs 9.00 20
More than 50 pcs 7.00
Note: An additional 6% for SST tax will be charged.

Write a complete program to do the following tasks:

a. Prompt the user to enter the product code and quantity. Display an error message if the
user entered an invalid code or if the quantity fails to meet the minimum number of orders.

b. Calculate the current order sales and print the receipt using the following example:

CURRENT ORDER BEFORE TAX

Total : RM XX.XX

c. The process will continue until the user enters 'N' to stop.

d. At the end of the process, print the summary report including tax. Your answer should be
display in two decimal places.

FGH Healthcare Sdn Bhd

CURRENT SALES AFTER TAX


Total Sales : RM XXX.XX
Tax : RM XX.XX
Total Sales after Tax : RM XXX.XX

(20 marks)

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 9 CS/JUL 2022/CSC415

QUESTION 2

Cuci-Cuci Service Sdn Bhd offer weekly payment for its employees with the regular rate is
RM15.00 and the rate is as follows:

Hours Rate
The first 20 hours Regular Rate (RM 15.00)
For next 20 hours 1.5 times the regular rate for each hour over 20 through 40
For over 40 Double the regular rate for each over 40

a. Write the definition of function void getData(). This function will read the employee's
name and the number of hours worked. This function then returns both data through its
reference parameters.

b. Write the definition of function calcGrossPay(). This function receives the number of
hours worked through its parameter. This function then calculates and returns the gross
pay.

c. From the employee’s gross pay, the following deductions are made:

11% for income tax deduction


9 % for EPF deduction
RM 20.00 for the employee’s club

Write the definition of function calcDeduction(). This function receives employee’s


gross pay and return the total deductions.

d. Write a main program to do the following:

• Write the statement to call function getData() with appropriate actual parameters
provided.
• Calculate the gross pay and deductions for each employee by calling function
calcGrossPay() and calcDeduction()
• Calculate the net pay for each employee:

Net pay = GrossPay – Deductions

• Display a slip for each employee that display the employee id, gross pay , deduction
and net pay.
• Calculate and display the total net pay for all employees in the company.
• This process will continue until the user requests to stop.

(20 marks)

END OF QUESTION PAPER

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy