how to make the number of passenger show the value from greatest the lowest
like 300, 290, 280, 270, 260....200 in output, and keep the profit and ticket price same.
AND how to find the great value and its ticket cost and its number of passenger
#include<iostream>
#include<iomanip>
#include<conio.h>
usingnamespace std;
int main()
{
int mip, //mininum passengers
map, //maximum passengers
np; //number of passengers
double tp, //proposed ticket price
fc, //fixed cost
ct, //cost of ticket
discount, profit;
char answer;
bool again=true;
while(again)
{
cout<<"Enter the Minimum Number of Passengers: ";
cin>>mip;
if (mip<0)
mip=mip*(-1);
if ((mip==0) || (mip>300))
mip=100;
cout<<"Enter the Maximum Number of Passengers: ";
cin>>map;
if (map<0)
map=map*(-1);
if ((map==0) || (map>500))
map=500;
cout<<"Enter the Proposed Ticket Price: ";
cin>>tp;
if (tp<0)
tp=tp*(-1);
if ((tp==0) || (tp>=100))
tp=20;
cout<<"Enter the Fixed Cost: ";
cin>>fc;
if (fc<0)
fc=fc*(-1);
if ((fc==0)||(fc>=10000))
fc=2500;
cout<<"Enter the discount per ticket per every group of 10 passengers: ";
cin>>discount;
if (discount<0)
discount=discount*(-1);
if ((discount==0)||(discount>=1))
discount=0.5;
system("cls");
np=mip;
while(np>map)
{
//if (np>map)
//{
cout<<"Error!...Mininum Passenger must Less than Maximum Passenger,\nEnter the Minimum Number of Passengers: ";
cin>>mip;
if (mip<0)
mip=mip*(-1);
if ((mip==0) || (mip>300))
mip=100;
cout<<"Enter the Maximum Number of Passengers: ";
cin>>map;
if (map<0)
map=map*(-1);
if ((map==0) || (map>500))
map=500;
//}
}
cout<<fixed<<showpoint<<setprecision(2);
cout<<"\nNumber of Passenger\t\tTicket Price\t\tProfit";
for (int np=mip; np<=map; np+=10)
{
ct=tp-(((np-mip)/10)*discount);
profit=(np*ct)-fc;
cout<<"\n\t"<<np<<"\t\t\t $"<<ct<<"\t\t$"<<profit;
}
cout<<"\n\nDo you wanna another run(y or n)? ";
cin>>answer;
switch (answer)
{
case'y':
again = true;
break;
case'n':
again = false;
break;
}
getch();
}
return 0;
}
Enter the Minimum Number of Passengers: 200
Enter the Maximum Number of Passengers: 300
Enter the Proposed Ticket Price: 25
Enter the Fixed Cost: 2500
Enter the discount per ticket per every group of 10 passengers: .5
Number of Passenger Ticket Price Profit
200 $25.00 $2500.00
210 $24.50 $2645.00
220 $24.00 $2780.00
230 $23.50 $2905.00
240 $23.00 $3020.00
250 $22.50 $3125.00
260 $22.00 $3220.00
270 $21.50 $3305.00
280 $21.00 $3380.00
290 $20.50 $3445.00
300 $20.00 $3500.00
Do you wanna another run(y or n)? n
Press Enter to return to Quincy...