This is what I have to do:
1.Create a variable named total (double floating point), a constant double variable named TAX=1.13.
2.Create and 10 element array of doubles (with a constant size declarer) and use an initialization list to set all the elements to zero.
3.Query the user to enter the price of up to ten items in the array (using a while loop). Have the user enter -99 to end entering data (if they choose to enter less than 10 items).
4.Call a function named sumall (which has a prototype before the main function and is defined after the main function) and pass the array and array length into it. The sumall function sums all the elements of the array and returns the total. Assign the output of the function to the variable ‘total’.
5.Have the computer tell the user the total of the bill plus tax.
Problem I can't seem to put a while loop in that tells the program to stop when -99 is entered I get errors or the program doesn't work. Any suggestions will help thanks!!
#include <iostream>
#include <iomanip>
usingnamespace std;
double total;
constdouble TAX = 1.13;
double item[10];
int i = 0;
double sumall()
{
for(int i = 0; i < 10; i++)
{
total += item[i];
}
total = total * TAX;
return 0;
}
int main()
{
cout<<"Please enter the prices: "<<endl;
for(int i = 0; i < 10; i++)
{
cin>>item[i];
}
sumall();
cout<<"The total, including tax, for all the groceries is $"<<setprecision(2) <<fixed<<total<<endl;
system("PAUSE");
return 0;
}