Question: Lab 1 2 : Write a program that keeps track of daily sales of 1 0 stores in an array and determine a ) Highest

Lab 12:
Write a program that keeps track of daily sales of 10 stores in an array
and determine
a) Highest sale and the store number (assume that the first store has the store number zero)
b) Lowest sale and the store number
c) Average sale No need to loop to take input multiple times.
input are in order:
10987654321
output needs to be:
Enter 10 sales numbers:
Highest sales: 1
Lowest sales: 10
Average sales: 5.5
please help fix my program to pull the last number as the highest number and the first as the lowest number.
#include
#include
#include
using namespace std;
int main()
{
//(a) Array to be searched - list
//(b) Number of elements in the array - length
//(c) Item that we are searching - searchItem
const int size =10;
int value[size]={1,2,3,4,5,6,7,8,9,10};
int index =0;
double location =-1;
bool found = false;
int searchItem =0;
cout << "Enter 10 sales numbers:";
do{
cin >> value[index];
index++;
}while(index < size);
while (location ==-1 && index < size){
if (value[index]== searchItem){
location = index;
index++;
}
}
if (found){
double highestStoreNumber, lowestStoreNumber;
highestStoreNumber = index;
lowestStoreNumber = index;
}
double highestStoreNumber ={10};
double lowestStoreNumber ={1};
double total =0;
double average;
for (int i =0; i < size; i++){
if (value[i]> highestStoreNumber)
highestStoreNumber = value[i];
if (value[i]< lowestStoreNumber)
lowestStoreNumber = value[i];
total += value[i];
}
average = total / size;
cout << "Highest sales: "<< highestStoreNumber << endl;
cout << "Lowest sales: "<< lowestStoreNumber << endl;
cout << "Average sales: "<< average << endl;
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!