Hi all,
Going straigt to the point here: This is what my end goal / prompt I need to achieve.
I have a project where it involves a set number of passengers. When passenger number reach 210 it will be need to increment by 10 until 500. As that happens with every increment the price of the ticket discounts by 00.50 every 10 increments. The base price is at $30.00 for passengers in quanitty of 209 and less.
The question is the passnger number will increment and then the price will be discounted. Is there a way to use a array to store the passenger values and the corresponding price so that it can be accessd and then COUT the matching numbers. To give the user the amount he entered in passenger and then COUT the matching price. Thanks for reading and sorry for any poor programming.
#include <iostream>
#include <cstdlib>
#include <iomanip>
usingnamespace std;
int main()
{
int minpass; // Minimum Passengers // Can NOT exceed 500 passengers
int maxpass; // Maximum Passengers // <--- User Inputs
int fixcost; // Fixed Cost // Can NOT exceed 500 passengers
float tickcost;
float price = 30.00;
float minprofit = 14.00;
cout << "Please enter the minimum amount of passengers: "; // User enters the amount of desired MINIMUM of passengers
cin >> minpass;
if ( minpass > 500 ) // IF statement to make sure the minimum amount of passengers does not EXCEED 500
{
cout << "You have exceeded the maximum amount of 500 passengers." << endl << endl; // COUT gives users warning that they have exceeded the MAXIMUM amount of passengers
return main(); // If the amount of exceed the MAX then the user will be returned to enter another amount
}
if ( minpass < 1 ) // IF statement to make sure the minimum amount is NOT less than 1
{
cout << "You did not meet the minimum amount of passengers." << endl << endl; // COUT give users warning that the amount of passengers have not met the MINIMUM amount
return main(); // IF the amount is less than the minimum then user will be returned to enter another amount
}
if ( minpass <= 209)
{
tickcost = minpass * price;
cout << "Total cost of " << minpass << " tickets at $30.00 comes to: $" << tickcost << endl;
}
for ( minpass >= 210; minpass <= 500; minpass+=10) // IF the minpass is equal or greater than 210 it will increment by 10
cout << minpass << endl;
for (price = price; price >= minprofit; price -=.50)
cout<< price << fixed << setprecision(2) << endl;
}