I'm given a problem in which the main function is already provided and I need to create a function that would calculated whatever is asked. I'm having problems trying to figure out how to overwrite the array in the main function with the new values I obtained from the function I created. So far, the end result is that it just prints out whatever is from the original array.
#include "stdafx.h"
//Windows Visual studio seems to want me to add this in order for it to work
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void change_price(float price[], float percent_change){
for (int j = 0; j < 8; j++){
(price[j] * (100 + percent_change)) / 100 ;
}
}
/*
This program inputs an array of item prices on sale
There is a 25% discount and the NY sales tax 8.875 is computed on the reduced price
It then prints the resulting prices
*/
int main(){
float prices[] = { 10, 27, 83, 15, 39, 120, 87, 20 };
change_price(prices, -25.0);
change_price(prices, 8.875);
cout << "final prices\n";
for (int i = 0; i < 8; i++)
cout << prices[i] << endl;
}