// A PROGRAM FOR PASSENGER FARE, THE SYSTEM MUST ASK THE USER TO ENTER AGE OF PASSENGER.IF AGE IS BELOW 12,THERE IS A 10% DISCOUNT, ELSE 5% DISCOUNT
// THE USER WILL NOW ENTER THE DESTINATION CODE TO COMPUTE THE FARE.
// CODE FARE
// CHINA 2500
// JAPAN 3000
#include <iostream>
#include <string>
using namespace std;
int main()
{
int age,china_fare,japan_fare;
double discount,discounted_fare;
char destination;
japan_fare=3000;
china_fare=2500;
cin>>age;
cin>>destination;
if (destination=japan_fare)(age>12)
discount=japan_fare*0.10;
discounted_fare=japan_fare-discount;
else if (destination=japan_fare)(age<12)
discount=japan_fare*0.05;
discounted_fare=japan_fare-discount;
else if (destination=china_fare)(age>12)
discount=china_fare*0.10;
discounted_fare=china_fare-discount;
else if (destination=china_fare)(age<12)
discount=china_fare*0.05;
discounted_fare=china_fare-discount;
cout<<age<<discount<<destination;
system ("pause");
return 0;
}
Firstly try and use braces around your if/else stuff.
This
if (destination=japan_fare)(age>12)
looks wrong. did you mean something like:
if (destination==japan_fare && age>12)
?
(note you need 2 '='s to test for equality).
Also, i see you are trying to read in 2 values and assign then to age and destination, but you have not prompted the user to do anything.
have a read of that link on file IO i pasted a few days ago.