Sample Report CSC128 Feb2017
Sample Report CSC128 Feb2017
PULAU PINANG
LAB PROJECT
CSC128 - Fundamentals of Computer Problem
Solving
MAKAJIL
4.
GROUP: G1/G2
PREPARED FOR
DATE
12/03/2017
Evaluation Form
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
Function menu ()
1.
2.
3.
Function calcPrice (int code,int 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
1.
2.
3. i. ii.
i. ii.
4.
5. i. ii.
6. i. ii.
7.
8.
9.
10.
Function main()
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
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);
}while(nextCustomer != 'n');
cout<<"Thank you"<<endl;
return 0;
}
4.0 SAMPLE OUTPUTS
Sample Output 1
Sample Output 2
CD/DVD
in an Envelope