Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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;
} number

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

305 mg of C6H12O6 in 55.2 mL of solution whats the molarity

Answered: 1 week ago

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago

Question

2. Discuss the types of messages that are communicated nonverbally.

Answered: 1 week ago