Assignment 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

CSC415

LAB ASSIGNMENT 1

QUESTION 1

Write a C++ program to calculate and display the coordinates of the midpoint of the line
connecting the two points whose coordinates are entered by user (x1,y1) and (x2, y2).
Use the fact that the coordinates of the midpoint between two points having coordinates
(x1, y1) and (x2, y2) are ((x1+x2)/2), ((y1+y2)/2). The display produced by
your program should be :

The x coordinate of the midpoint is xxx.xx

The y coordinate of the midpoint is yyy.yy

where xxx.xx and yyy.yy denotes that the calculated value should be places in a field
wide enough for three places to the left of the decimal point and two places to the right of it.

NORMAZIAH - FSKM
CSC415

QUESTION 2

Write a program to create a customer’s bill for a company. The company sells five computer
devices which are Mouse, Keyboard, Printer, Pen drive and Speaker. The unit prices are
RM35.00 per pack, RM175.00, RM350. RM32.00 and RM105.50, respectively. The program
must read from the keyboard the quantity of each piece of equipment purchased. It then
calculates the cost of each item, the subtotal, sale and service tax (SST= 8%) and the total
cost after SST.

The input data consists of a set of integers representing the quantities of each items sold.

Example of the input is shown below:

PLEASE ENTER QUANTITY OF MOUSE SOLD : 5

PLEASE ENTER QUANTITY OF KEYBOARD SOLD : 3

PLEASE ENTER QUANTITY OF PRINTER SOLD : 2

PLEASE ENTER QUANTITY OF PEN DRIVE SOLD : 25

PLEASE ENTER QUANTITY OF SPEAKER SOLD : 10

The format for the output is as below:

QUANTITY DETAILS UNIT PRICE(RM) TOTAL PRICE


-------------- ------------- ---------------------- -----------------
XX MOUSE 35.00 XXXX.XX
XX KEYBOARD 175.00 XXXX.XX
XX PRINTER 350.00 XXXX.XX
XX PEN DRIVE 32.00 XXXX.XX
XX SPEAKER 105.50 XXXX.XX
-----------------
SUBTOTAL XXXXX.XX
SST XXX.XX
TOTAL XXXXX.XX
------------------

* Use constant for the unit prices and the SST rate.

Due Date : Thusday 2 May 2024 before 5 pm in UFuture

NORMAZIAH - FSKM

You might also like