Professional Documents
Culture Documents
TABLE OF CONTENT 1
INTRODUCTION 2
PROBLEM 3
ANALYSIS 4
ALGORITHM 5
THE PROGRAM 8
THE OUTPUT 11
1
Introduction
In this project had two author, Adam and Mursyid that contribute to finish this
project. Our team take about 2 weeks to finish this project.
This project our team need to solve the problem from the question given to write
a program using C++ programming language which will calculate the total price depend
from the price of rate per day for each type of package that will choose by each guest.
After that the program will need to print receipt to display guest name, type of package,
number of days and total payment amount that guest has to pay. Before the end of the
program, the following final report must be display to show the total collection for the
day, the total number of guest for each type of package, the average price per guest
and lastly is to show highest and lowest price between of all the total payment from
each guest.
Before do the program, we make analysis to identify the problem and list out the
data to use to solve the problem. Then we need to make an algorithm using flow chart
to solve the problem. After that, we can write the C++ program based on the flow chart
to solve the problem.
2
Problem
3
Analysis
Input Output
bookType total
name hPrice
packType lPrice
nDays sum
cntA
cntF
cntD
cntS
avg
Process
if packType == A(apartment) :
If bookType == 'O'
4
Algorithm
total
cntA
cntF
cntD
cntS
5
6
7
The program
/*
Proogram to calculate price in Paradise Resort
Created by Adam and Mursyid on 3 December 2018
*/
#include <iostream>
#include <string>
int main()
{
char bookType, packType;
string name;
int nDays, cntTotal, cntA=0, cntF=0, cntD=0, cntS=0;
double avg, sum, price,disPrice, subTotal, lPrice=0.0, hPrice=0.0, total;
8
Else
{
if(packType == 'S')
{
cntS++;
}//if
else
{
cout<<"Error input"<<endl;
}//else
}//else if
}//else if
}//else if
cout << "Number of Days(s) : ";
cin >> nDays;
total = calPrice(packType,nDays,bookType);
cout << "Total Payment (RM) : " << total<<endl;
if(total > hPrice)
{
hPrice = total;
}//if
if((lPrice < total) || (total < lPrice))
{
lPrice = total;
}//if
sum += total;
cout << "\nThank You. Please Come Again." <<endl<<endl;
9
double calPrice(double packType,int nDays,char bookType)
{
double tax = 0.0, disPrice = 0.0, total = 0.0, price = 0.0;
if(packType == 'A')
{
price = 350 * nDays;
}//if
else
{
if(packType == 'F')
{
price = 250 * nDays;
}//if
else
{
if(packType == 'D')
{
price = 200 * nDays;
}//if
else
{
if(packType = 'S')
{
price = 150 * nDays;
}//if
}//else if
}//else if
}//else if
if(bookType == 'O')
{
disPrice = 0.85 * price;
tax = 0.05 * disPrice;
total = tax + disPrice;
}//if
else
{
if(bookType == 'M')
{
tax = 0.05 * price;
total = tax + price;
}//if
}//else
return total;
}//function calPrice
10
The output
11