You are on page 1of 14

UNIVERSITI TEKNOLOGI MARA

PULAU PINANG

LAB PROJECT
CSC128 - Fundamentals of Computer Problem
Solving

GAGARAN CAR SELL


PREPARED BY:

Group Members Matric No

1.KEVIN NOEL ALEXIUS 2015883372

2.RANDAL PAUL FREDERICK 2015815276

MAKAJIL

3. AKMAL HAFIZI BIN ANNUAR 2015820968

4.

GROUP: G1/G2

PREPARED FOR

Madam Naemah Abdul Wahab

DATE

12/03/2017
Evaluation Form

(download from i-learn


Table of Content
i. SYNOPSIS
ii. ANALYSIS AND FLOWCHART
iii. SOURCE CODE

iv. SAMPLE OUTPUTS


1.0 SYSTEM SYNOPSIS

The program should allow user to input car brand code and car details code.
After that, the user will input their downpayment along with years of payment to
calculate their estimated monthly payment. User can look for another car by
repeat the process until user enter ‘y’ for buying the selected car. If the user
planning to buy the car, the user will have to input their full name, Ic number,
home address and phone number. An error message will be display for any
invalid car brand code. The display of order will output the user name, Ic
number, phone number, home address, car brand, car name, car price,
downpayment, years of payment and monthly payment.
2.0 ANALYSIS AND FLOWCHART

Function menu ()

Input: -

Process: 1. BEGIN
2. Display code and destination
3. END

Output: Display code and destination menu

Function menu ()

1.

2.

3.
Function calcPrice (int code,int quantity)

Input: code and quantity

Process:
1. BEGIN
2. DECLARE double ticketPrice, totalPrice, insurance;
i. string destination;
3. If code = 1
i. Assign ticketPrice = 45;
ii. Assign destination = “Kuala Lumpur”;
4. else if code = 2
i. Assign ticketPrice = 28
ii. Assign destination = “Ipoh”;
5. else if code = 3
i. Assign ticketPrice = 55
ii. Assign destination = “Kuala Terengganu”;
6. else
i. Assign ticketPrice = 0
ii. Assign destination = “Invalid destination code”;
7. CALCULATE insurance = ticketPrice*0.05;
8. CALCULATE totalPrice = (ticketPrice + insurance) * quantity;
9. DISPLAY code, destination, quantity, ticketPrice, insurance, totalPrice
10. END

Output: code, destination, quantity,ticketPrice,insurance,totalPrice


Function calcPrice (int code,int quantity)

1.

2.

3. i. ii.
i. ii.
4.

5. i. ii.

6. i. ii.

7.

8.

9.

10.
Function main()

Input: code, quantity, nextCustomer

Process: 1) BEGIN
2) DECLARE int code, quantity;
char nextCustomer;
3) REPEAT if answer is yes
a. Call function menu()
b. Input code, quantity
c. Call function calcPrice(code,quantity)
d. Input repeat next customer
4) DISPLAY “thank you” message
5) END

Output: -
Function main()

1.

2.

yes
3.

a.

b.
c.

d.
no

4.

5.
3.0 SOURCE CODE

#include <iostream>
using namespace std;
void menu(); //function prototype
void calcPrice(int,int); //function prototype

void menu() //function definition


{
cout<<endl;
cout<<" Code\t\tDestination"<<endl;
cout<<"-------------------------------"<<endl;
cout<<" 1\t\tKuala Lumpur"<<endl;
cout<<" 2\t\tIpoh"<<endl;
cout<<" 3\t\tKuala Terengganu"<<endl;
cout<<endl;
}

void calcPrice(int code,int quantity) //function definition


{
double ticketPrice, totalPrice, insurance;
string destination = "";

if(code == 1)
{
ticketPrice = 45;
destination = "Kuala Lumpur";
}
else if(code == 2)
{
ticketPrice = 28;
destination = "Ipoh";
}
else if(code == 3)
{
ticketPrice = 55;
destination = "Kuala Terengganu";
}
else
{
ticketPrice = 0;
destination = "Invalid destination code.";
}
insurance = ticketPrice*0.05;
totalPrice = (ticketPrice + insurance) * quantity;

cout<<endl;
cout<<"-----------------------------------------------"<<endl;
cout<<" Destination Code\t\t: "<<code<<endl;
cout<<" Destination\t\t\t: "<<destination<<endl;
cout<<" Quantity\t\t\t: "<<quantity<<endl;
cout<<" Ticket Price\t\t\t: RM "<<ticketPrice<<endl;
cout<<" Insurance\t\t\t: RM "<<insurance<<endl;
cout<<" Ticket Price with Insurance\t: RM "<<totalPrice<<endl;
cout<<"-----------------------------------------------"<<endl;
cout<<endl;
}

int main()
{
int code, quantity;
char nextCustomer;

do
{
menu(); //function call
cout<<"Enter destination code, 1/2/3: ";
cin>>code;
cout<<"Enter quantity of ticket: ";
cin>>quantity;

cout.setf(ios::fixed);
cout.precision(2);

calcPrice(code, quantity); //function call

cout<<"Do you want to buy another ticket? y-yes, n-no: ";


cin>>nextCustomer;

}while(nextCustomer != 'n');

cout<<"Thank you"<<endl;

return 0;
}
4.0 SAMPLE OUTPUTS

Sample Output 1
Sample Output 2
CD/DVD
in an Envelope

You might also like