Thursday, 5 September 2013

Code not working?

Code not working?

I'm new here and am just learning c++. As an homework I've started to try
the branching.. but I didn't quite get the hang of it... here's the code
I've tried to perform (please bear patience with me if I'm making huge
mistakes..)
/*
* The Royal Academy Theater was so pleased with
* our previous work they decided to ask for an
* additional enhancement, which of course we get
* to charge them for. They need a flag to handle
* when the movie is R-rated. Modify the program
* above to prompt the user for whether the movie is
* R-rated, and if the customer is aged 13 or younger,
* print an additional notice that the customer must
* be accompanied by a parent or guardian
*/
#include <iostream>
using namespace std;
int main () {
int age;
char * yes;
char * no;
bool Rated = Rated ? yes : no;
int ticketPrice = 5;
int discountPrice = ticketPrice - (ticketPrice * 0.1);
int matineePrice = (ticketPrice * 0.5);
int hour = 8 <= hour <= 24;
cout << "Is the movie R_rated? \n";
cin >> yes or no;
cout << "How old are you?";
cin >> age;
if (age < 0 or age >100) {
cout << "Not a valid age!";
}
else if ((age <= 13) and (Rated = yes)) {
cout << "You must be accompanied by a Janitor";
}
else if (((age > 13) and ((Rated = yes) or (Rated = no)))
or ((age <=13) and (Rated = yes))) {
cout << "What time do you want the ticket for?";
cin >> hour;
if (hour < 8 or hour > 24) {
cout << "Not a valid hour!";
}
else if (hour < 18) {
if (age <= 5) {
cout << "The entrance is free";
}
else if (age >= 55) {
cout << "Matinee Ticket price is "<<
matineePrice;
}
else if (5 < age < 55) {
cout << "Matinee ticket price is " << matineePrice;
}
}
else if (hour >= 18) {
if (age <= 5) {
cout << "The entrance is free";
}
else if (5 < age <= 55) {
cout << "Ticket price is " << ticketPrice;
}
else if (age > 55) {
cout << "You're eligibile for a 10% "
"discount \n";
cout << "Ticket price is " << discountPrice;
}
}
}
}
For example -- I get the lines below (to which I answer 'no', '67', and
'20') and I should get the discountedPrice instead of the ticketPrice
value...
Is the movie R_rated?
no
How old are you?67
What time do you want the ticket for?20
Ticket price is 5
Any suggestion (I'm a newbie :[ ) would be really appreciated... Thank you
very much

No comments:

Post a Comment