beginner,want this program to call the relevant functions,calculate final price
Sep 14, 2014 at 3:22pm UTC
Hi I am a beginner in programming I want this programming to call functions choose between a customer type and call the relevent function to calculate the final price but it is not calling the functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
#include <iostream>
using namespace std;
double amount;
double studendOrPensioner(int &choice, double &origPrice);
double OtherCustomers(int &choice,double & origPrice);
int main()
{
int customertype;
cout<<"s. Student\n" ;
cout<<"S. Student\n" ;
cout<<"p. Pensioner\n" ;
cout<<"P. Pensioner\n" ;
cout<<"O. Other customers: " ;
cin>> customertype;
switch ( customertype ) {
case 's' :
case 'S' : // Note the colon, not a semicolon
case 'p' : // Note the colon, not a semicolon
case 'P' :
cout << "You have selected pensioner or student" << endl;
double studendOrPensioner(int &choice, double &origPrice);
break ;
case 'o' :
case 'O' : // Note the colon, not a semicolon
cout<<"You have selected other customers " ;
double OtherCustomers(int &choice,double & origPrice);
break ;
}
return 0;
}
double studendOrPensioner(int &choice,double & origPrice)
{
cout << "You have selected a student or a pensioner " ;
cout << "Enter choice " ;
cout << "100 for ticket only" ;
cout << "200 for ticket and popcorn" ;
cin >> choice;
if (choice == 100){
cout << "Please enter the original price: " ;
cin >> origPrice;
double pay;
pay = origPrice - (origPrice * 20 / 100);
return pay;
} else
{
pay = origPrice - (origPrice * 10/ 100);}
}
double OtherCustomers(int &choice,double & origPrice)
{cout << "You have selected a student or a pensioner " ;
cout << "Enter choice " ;
cout << "100 for ticket only" ;
cout << "200 for ticket and popcorn" ;
cin >> choice;
if (choice == 100){
cout << "Please enter the original price: " ;
cin >> origPrice;
double pay;
pay =origPrice - (origPrice * 20 / 100);
return pay;
}
else {
origPrice;}
}
Last edited on Sep 15, 2014 at 12:30pm UTC
Sep 14, 2014 at 5:14pm UTC
Use code tags
http://www.cplusplus.com/articles/jEywvCM9/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#include <iostream>
using namespace std;
double amount;
double studendOrPensioner(int &choice, double &origPrice);
double OtherCustomers(int &choice,double & origPrice);
int main()
{
int customertype;
cout<<"s. Student\n" ;
cout<<"S. Student\n" ;
cout<<"p. Pensioner\n" ;
cout<<"P. Pensioner\n" ;
cout<<"O. Other customers: " ;
cin>> customertype;
switch ( customertype ) {
case 's' :
case 'S' : // Note the colon, not a semicolon
case 'p' : // Note the colon, not a semicolon
case 'P' :
cout << "You have selected pensioner or student" << endl;
double studendOrPensioner(int &choice, double &origPrice);
break ;
case 'o' :
case 'O' : // Note the colon, not a semicolon
cout<<"You have selected other customers " ;
double OtherCustomers(int &choice,double & origPrice);
break ;
}
cin.get();
}
double studendOrPensioner(int &choice,double & origPrice)
{
cout << "You have selected a student or a pensioner " ;
cout << "Enter choice " ;
cout << "100 for ticket only" ;
cout << "200 for ticket and popcorn" ;
cin >> choice;
if (choice == 100){
cout << "Please enter the original price: " ;
cin >> origPrice;
return origPrice - (origPrice * 20 / 100);
} else
{
origPrice - (origPrice * 10/ 100);}
}
origPrice - (origPrice * 10/ 100);} result is not being used and your double function does not return a double
double OtherCustomers(int&choice,double& origPrice)
{cout << "You have selected a student or a pensioner ";
cout << "Enter choice ";
cout << "100 for ticket only";
cout << "200 for ticket and popcorn";
cin >> choice;
if (choice == 100){
cout << "Please enter the original price: ";
cin >> origPrice;
return origPrice - (origPrice * 20 / 100);
}
else {
origPrice;}
}
origPrice;} result is not being used and your double function does not return a double
Topic archived. No new replies allowed.