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
|
//Intermediate25.cpp - increases the prices stored in an
//array and then displays the increased prices
//Created/revised by <your name> on <current date>
#include <iostream>
#include <iomanip>
using namespace std;
double getIncrease();
void increasePrice(double amount[], double pI);
void displayArray(double amount[], int numElements);
int main()
{
cout << fixed << setprecision(2);
//declare array
double prices[10] = {10.5, 25.5, 9.75, 6.0, 35.0, 100.4, 10.65, .56, 14.75, 4.78};
double increase = 0.0;
//get input
increase = getIncrease();
increasePrice(prices, increase);
displayArray(prices, 10);
system("pause");
return 0;
} //end of main function
/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */
double getIncrease()
{
double up = 0.0;
cout << "Enter a percentage in which to increase prices by: % ";
cin >> up;
return up;
}// end of GetSales function
void increasePrice(double amount[], double pI)
{
for(int i = 0; i > 10; i++)
{
amount[i] = amount[i] * pI;
}//end for statment
}//end of increasePrice Function
void displayArray(double amount[], int numElements)
{
cout << fixed << setprecision(2) << endl << endl;
for (int sub =0; sub < numElements; sub +=1)
{
cout << "Price of Item " << sub + 1 << " after increase: $";
cout << amount[sub] << endl;
}// end for
}// end of displayArray function
|