Connecting Tech Pros Worldwide Forums | Help | Site Map

C++ newb problem

Newbie
 
Join Date: Nov 2006
Posts: 3
#1: Nov 14 '06
hello ive just started learning c++ and im really stuck. the program doesnt seem to beable to read the if statement properly

# include <iostream>
using namespace std;

int getDaysHire(int);
int calculateCharge(int daysHire, int seasonCharge);// my two function prototypes

int main()
{
int x;
int season;
int cost;
int DaysHire;
int seasonCharge;
int days;

cout << " Enter the number of days you wish to rent a bicycle. Bearing in mind that a £25 deposit must be paid";
cout << " The maxium days allowed is 15 and if you rent over 8 days you will get a 10% discount.";

days = getDaysHire(x);// function call

cost = calculateCharge(DaysHire,seasonCharge);


cout << "the cost is" << cost << endl; // my output statement
system("PAUSE");
// wait until user is ready before terminating program
// to allow the user to see the program results
return 0; // program has ended
}

int getDaysHire(int days)// function defination
{

cin >> days;// user inputs days that they want to rent a bicycal for

if (days <= 15)
cout <<" ok";
else if (days > 15)
{
cout << "read the instructions moron, ENTER DAYS LESS THAN 15";
cin >> days;

}


return days;
}

int calculateCharge(int DaysHire, int seasonCharge)
{
int cost,season,high,low,days;

cout <<"is it high season or low season";
cin >> season;

if (season == low && days >8)
cost =(((5+25/100)*10)*days);
else if ( season == high && days >8)
cost =(((10+25/100)*10)*days);
else if (season == low && days <8)
cost =((5+25)*days);
else if ( season == high && days <8)
cost =((10+25)*days);


return cost;
}

thank you foer helping



Newbie
 
Join Date: Aug 2006
Posts: 9
#2: Nov 15 '06

re: C++ newb problem


hi,

in int main()

u forget to capture the number of days.. where is ur cin >> x;
Newbie
 
Join Date: Aug 2006
Posts: 9
#3: Nov 15 '06

re: C++ newb problem


hi,

in int main()

u forget to capture the number of days.. where is ur cin >> x;
Newbie
 
Join Date: Nov 2006
Posts: 3
#4: Nov 15 '06

re: C++ newb problem


days = getDaysHire(x);// function call is where my x is and i supposed to go to the function thats where the user types in the number of days


Quote:

Originally Posted by christine0207

hi,

in int main()

u forget to capture the number of days.. where is ur cin >> x;

Reply