Question

Can someone please assist me in this c++ problem below?, thanks Write program that keeps daily...

Can someone please assist me in this c++ problem below?, thanks

Write program that keeps 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

Homework Answers

Answer #1
#include <iostream>

using namespace std;

int main()
{
   float arr[10], sum = 0;
   int n = 10, min, max;
   
   cout<<"Enter daily sales of 10 stores:"<<endl;
   for(int i = 0;i<n;i++){
      cin>>arr[i];
   }
   
   min = 0;
   for(int i = 1;i<n;i++){
       sum += arr[i];
      if(arr[min] > arr[i]){
         min = i;
      }
   }
   
   max = 0;
   for(int i = 1;i<n;i++){
      if(arr[max] < arr[i]){
         max = i;
      }
   }
   
   cout<<"Array: ";
   for(int i = 0;i<n;i++){
      cout<<arr[i]<<" ";
   }
   cout<<endl;
   
   cout<<"Highest sale is "<<arr[max]<<" and the store number is "<<max<<endl;
   cout<<"Lowest sale is "<<arr[min]<<" and the store number is "<<min<<endl;
   cout<<"Average sale = "<<(sum/10.0)<<endl;
   
    return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please answer in C++ with the correct files (in bold). Thanks! Write a program that creates...
Please answer in C++ with the correct files (in bold). Thanks! Write a program that creates three identical arrays, list1, list2, and list3, of 5000 elements. The program then sorts list1 using bubble sort, list2 using selection sort, and list3 using insertion sort and outputs the number of comparisons and item assignments made by each sorting algorithm. Please use the file names listed below since your file will have the following components: Ch18_Ex15.cpp searchSortAlgorithms.h
Write a program in C++ that inputs an unknown number of test scores (assume that there...
Write a program in C++ that inputs an unknown number of test scores (assume that there is a maximum of 150 scores). Ask the user how many scores that they will be entering. The program should have at least 3 functions. Make sure the functions perform the following: Calculate the average score Find the highest score Find the lowest score Sort the list from highest to lowest Output the number of scores, the average, the sorted list, the highest, and...
Can someone please write me a college-level physics question about collisions or angular momentum, then give...
Can someone please write me a college-level physics question about collisions or angular momentum, then give 4 answer choices with only one being right, and then go through the steps of how you got the right answer, along with how I could possibly get the wrong answer if I messed up somewhere during the problem......Thanks
C++ Visual Studio 2019 Write a C++ console application that accepts up to 5 numbers from...
C++ Visual Studio 2019 Write a C++ console application that accepts up to 5 numbers from the user. Display all numbers, the highest, the lowest, and the average of the numbers. Ask the user if they want to continue entering another set of numbers. 1) Use proper naming conventions for your variables and functions. 2) Tell the user what the program is all about. Do NOT start the program with “Enter a number”!! 3) Create an array to store the...
(C language) <stdio.h> decisions (else if or switch) Write a program to calculate the average of...
(C language) <stdio.h> decisions (else if or switch) Write a program to calculate the average of the 2 highest numbers entered. Ask the user to enter 3 integers, determine which 2 integers are the 2 highest, and then calculate and display the average of the 2 highest numbers. Format the answer to 2 decimal places. The numbers can be entered in any sequence - lowest to highest, highest to lowest, or completely random. A decision block will be necessary to...
C++ INSTRUCTIONS Problem Specification : Write a program that reads a group of numbers from the...
C++ INSTRUCTIONS Problem Specification : Write a program that reads a group of numbers from the user and places them in an array of type float. Once the numbers are stored in the array, the program should average and print the result. Use pointer notation wherever possible. Program Output (with Input Shown in Bold): Enter number: 2 Enter another (y/n)? y Enter number: 4 Enter another (y/n)? y Enter number: 6 Enter another (y/n)? y Enter number: 8 Enter another...
Please write a C++ program to read a list of numbers from a datafile, and calculate...
Please write a C++ program to read a list of numbers from a datafile, and calculate the average, lowest and largest number. Please use the following command to copy the datafile scores.txt to your home directory: Please use end-of-file loop to read all the floating-point numbers from the datafile scores.txt. Please display the average, lowest and largest number of all the numbers in the datafile. Please create a function to process the datafile, and call the dataProcessing function in the...
Write a C++ program that reads data from a file, stores data in a one-dimensional array,...
Write a C++ program that reads data from a file, stores data in a one-dimensional array, and processes data as required. 1) Create a text file named “hw2data.txt” that contains student test scores in the range of 0~100. You can use the following sample data: 76.5 84 75 62 94.5 75.7 93 54 36.5 87.3 81.5 89.5 68 90 79.5 80 92.5 84 96 100 67.7 78 84.5 47 100 87.5 76.25 87 82.5 64 2) Read test scores from...
Write a C program Design a program that uses an array to store 10 randomly generated...
Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...
Please write code in C. Thank you! Write a program that reads a list of integers,...
Please write code in C. Thank you! Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input begins with an integer indicating the number of integers that follow. You can assume that the list will have at least 2 integers and less than 20 integers. Ex: If the input is: 5 10 5 3 21 2 the output is: 2 3 To achieve the above, first read...