You are on page 1of 11

Table of Conten

TABLE OF CONTENT 1

INTRODUCTION 2

PROBLEM 3

ANALYSIS 4

ALGORITHM 5

THE PROGRAM 8

THE OUTPUT 11

1
Introduction

C++ is a general purpose programming language that is free _ and compiled. It is


regarded as an intermediate level language as it comprises both high level and low
level language features it provided imperative, oriented and generic programming
features.

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

Calculation in - double calPrice (double packType,int nDays,char bookType) :

if packType == A(apartment) :

Compute price = 350 * nDays;

else - If packType == ‘F’(family) :

Compute price = 250 * nDays;

else - if packType == ‘D’ (Deluxe) :

Compute price = 200 * nDays;

else - if packType == ‘S’ (Standard) :

Compute price = 150 * nDays;

Calculation to find total :

If bookType == 'O'

Compute disPrice = 0.85 * price

tax = 0.05 * disPrice

total = tax + disPrice

else – if bookType == 'M'

Compute tax = 0.05 * price

total = tax + price

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>

using namespace std;

double calPrice(double packType,int nDays,char bookType);

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;

cout <<"Proogram to calculate price in Paradise Resort"<<endl;


cout << "Book Type (O-Online/M-Manual) = ";
cin >> bookType;
while(bookType != 'E')
{
cout << "\n\nPARADISE RESORT" <<endl;
cout << "#########################################" <<endl;
cout << "Guest Name : ";
cin >> name;
cout << "Type Of Package : ";
cin >> packType;//room type
if(packType == 'A')
{
cntA++;
}//if
else
{
if(packType == 'F')
{
cntF++;
}//if
else
{
if(packType == 'D')
{
cntD++;
}//if

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;

cout << "\nBook Type (O-Online/M-Manual) = ";


cin >> bookType;//next guest
}//while//loop stop when input E in bookType
cout <<"The total collection for the day is : "<<sum<<endl;
cout <<"The number of guest for package : "<<endl;
cout <<" Apartment : "<<cntA<<endl;
cout <<" Family: "<<cntF<<endl;
cout <<" Deluxe: "<<cntD<<endl;
cout <<" Standard: "<<cntS<<endl;
cntTotal = cntA+cntF+cntD+cntS;
avg = sum / cntTotal;
cout <<"The average price per guest is : "<<avg<<endl;
cout <<"The highest price is : "<<hPrice<<endl;
cout <<"The lowest price is : "<<lPrice<<endl;
cout <<"End of program" <<endl <<endl;
}//main

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

You might also like