help..find the max value

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


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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include<iostream>
#include<iomanip>
#include<conio.h>
using namespace 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...
Last edited on
closed account (iAk3T05o)
Arrays
Topic archived. No new replies allowed.