hello im a noobie when it comes to programing ive been strugling on this assignment all day would some one please show me how i can complete this task
Programming Assignment on Arrays
Write a program that asks the user for the prices of several items and stores them in an array.
1. You can ask them how many items there will be and you can assume that there will
never be more than 100. You must make sure that they do not ask for more than 100 in
your code
2. Then it asks the user for an amount they wish to spend (on one item).
3. It outputs the items that can be purchased with that amount of money after a 6.75% tax
has been added. You will have to refer to the item by its subscript (it would be better to
store the name of the item as well but that is too complicated for now).
4. So the output could look like this:
You can buy one of the following items with your $5:
Item 4, which will cost $3.8515 after tax.
Item 7, which will cost $4.7325 after tax.
Item 8, which will cost $2.9895 after tax.
Call a separate function that calculates the cost of an item after the tax has been added to it.
Make it reusable by passing the tax (as well as the price) as parameters.
int main ()
{
const int NUMBER_OF_ELEMENTS = 100;
int numberList[NUMBER_OF_ELEMENTS];
cout << "How many items are you going to store(under 100): ";
int maxNumber;
cin >> maxNumber;
double total = 0;
for (int ctr = 0; ctr < maxNumber; ctr ++)
{
cout << "Item number " << (ctr +1) << " cost: $";
cin >> numberList[ctr];
total = total + numberList[ctr];
}
int MaxAmount;
cout<<"Please enter the amount you wish to spend (on one item)";
cin>>MaxAmount;
The assignment requires you to write a function that accepts as parameters the cost of the item and the tax rate and returns the total cost after the tax is applied.
Your last for loop has to go through each item in the array, calculate its final cost, and output it provided that the final cost is no more than MaxAmount.
Your if() statement isn't quite correct because it is checking the cost of the item BEFORE tax is applied.
Fill in the blanks. The first blank is because your terminating condition is wrong; it loops through 100 items even if the user only entered 2. The second blank is for you to figure out the data type of finalCost.