I am just learning how to use C++ and I am anxious to do so..
I need help with working with double selection if statements.
Here is what I am trying to accomplish with in my program:
If a client selects to travel to Japan he is charged a flat rate, however, if is qualified for a Bronze level membership he is eligible for 10% discount, a Silver level qualifies him for 15% discount.
If you notice from the code below you will see that my coding has a logical error. When I submit him as a Silver level (15% discount), well you can see that it does not change to the proper coding and calculations. Can someone please help me?
First, I have commented out sections (/* and */ with //) just to by pass and hasten my testing. I did not include my header file with this code.
Secondly, i have problems when the code gets to the if((ClientMembership=="Bronze..... etc. Again, the country and discount rate are joined together.
Thank you for any help given.
#include "Reservation.h"
Client::Client(string number)
{
displayForm();
}
//setters
//void Client::setClientNumber(string number) {clientNumber = number;}
void Client::setClientName(string name) {clientName = name;}
void Client::setClientAddress(string address) {clientAddress = address;}
void Client::setClientState(string stateName) {clientState = stateName;}
void Client::setClientPhone(string phone) {clientPhone = phone;}
void Client::setClientPassport(string pass) {clientPassport = pass;}
void Client::setClientMembership(string members) {clientMembership = members;}
void Client::setClientDestination(string terminal) {clientDestination = terminal;}
void Client::setClientTripPrice(string price) {clientTripPrice = price;}
void Client::setClientDiscount(string discount) {clientDiscount = discount;}
//getters
//string Client::getClientNumber() {return clientNumber;}
string Client::getClientName() {return clientName;}
string Client::getClientAddress() {return clientAddress;}
string Client::getClientState() {return clientState;}
string Client::getClientPhone() {return clientPhone;}
string Client::getClientPassport() {return clientPassport;}
string Client::getClientMembership() {return clientMembership;}
string Client::getClientDestination() {return clientDestination;}
string Client::getClientTripPrice() {return clientTripPrice;}
string Client::getClientDiscount() {return clientDiscount;}
//member function
void Client::displayForm()
{
string input;
cout<<"******************************************************* \n";
cout<<"***** R e s e r v a t i o n S y s t e m ***** \n";
cout<<"******************************************************* \n\n";
cout<<" Type one of the following options: \n\n";
cout<<" --- New : Enter a new Reservation \n";
cout<<" --- Exit : Exit the Reservation System \n\n";
/* cout<<" Enter client's Name \t\t\t";
getline(cin, input);
setClientName(input);
cout<<" Enter client's Street Address: \t";
getline(cin, input);
setClientAddress(input);
cout<<" Enter client's State: \t\t\t";
getline(cin, input);
setClientState(input);
cout<<" Enter client's phone number: \t\t";
getline(cin, input);
setClientPhone(input);
cout<<" Does the client have a passport? Y/N: ";
getline(cin, input);
setClientPassport(input);
*/
cout<<" Membership Level: \n";
cout<<"\t\t\t\t\t1. Bronze \n";
cout<<"\t\t\t\t\t2. Silver \n";
cout<<"\t\t\t\t\t3. Gold \n";
cout<<"\t\t\t\t\t4. Platinum \n";
cout<<" Enter client's Membership: \t\t";
getline(cin, input);
setClientMembership(input);
cout<<"\n";
cout<<" Trip Destination: \n";
cout<<"\t\t\t\t\t1. Italy \n";
cout<<"\t\t\t\t\t2. France \n";
cout<<"\t\t\t\t\t3. Japan \n";
cout<<"\t\t\t\t\t4. South America \n";
cout<<" Enter client's Destination: \t\t";
getline(cin, input);
setClientDestination(input);
}
void Client::displayClientInfo()
{
cout<<"\n __________________________________________________ \n";
cout<<"****** Reservation Receipt ****** \n";
cout<<"\n __________________________________________________ \n";
cout<<" Client's Name: \t\t\t"<<getClientName()<<endl;
cout<<" Client's Street Address: \t\t"<<getClientAddress()<<endl;
cout<<" Client's State: \t\t\t"<<getClientState()<<endl;
cout<<" Client's Phone Number: \t\t"<<getClientPhone()<<endl;
cout<<" Client's Passport: \t\t\t"<<getClientPassport()<<endl;
cout<<" Client's Membership: \t\t\t"<<getClientMembership()<<endl;
cout<<" Client's Destination: \t\t\t"<<getClientDestination()<<endl;
cout<<" \n";
double clientDiscount;
double clientTotalPrice;
double result;
if((clientMembership=="Bronze \n")||(clientMembership=="bronze \n"));
cout<<"Client has Bronze therefore 10% discount off Total Price\n";
if((clientDestination=="Japan \n")||(clientDestination=="japan \n"));
clientDiscount = .90;
clientTripPrice = 7113;
result = clientTotalPrice * clientDiscount;
cout<<" The price is a total of : \n"<<result<<endl;
if((clientMembership=="Bronze \n")||(clientMembership=="bronze \n"));
cout<<"Client has Bronze therefore 15% discount off Total Price\n";
if((clientDestination=="Japan \n")||(clientDestination=="japan \n"));
clientDiscount = .85;
clientTotalPrice = 7113;
result = clientTotalPrice * clientDiscount;
cout<<" The price is a total of : "<<result<<endl;
//goto ten;
/* if((clientMembership=="Gold \n")||(clientMembership=="gold \n"));
cout<<"Client has Gold Membership, therefore 20% discount off Total Price\n";
discountMembershipPrice = .80;
if((clientDestination=="Japan \n")||(clientDestination=="japan \n"));
clientTotalPriceJapan = 7113;
goto ten;
if((clientMembership=="Platinum \n")||(clientMembership=="platinum \n"));
cout<<"Client has Platinum Membership, therefore 25% discount off Total Price\n";
discountMembershipPrice = .75;
if((clientDestination=="Japan \n")||(clientDestination=="japan \n"));
clientTotalPriceJapan = 7113;
*/
//ten:
//result = clientTotalPrice * discountMembershipPrice;
//cout<<" The price is a total of : "<<result<<endl;
system("pause");
}