This program is for C++. Write a program that allows a user to enter 12 double v
ID: 3550762 • Letter: T
Question
This program is for C++.
Write a program that allows a user to enter 12 double values representing store sales for each month of one year. After all 12 values are entered, display each month's sales amount and a message indicating whether it is higher, lower, or equal to the average month's sales. Name file MonthlySales.cpp
This is supposed to be a C++ program and it is for chapter 5 in the book. All I ask is that you used things learned up to chapter 5 if it is anything confusing or way past chapter 5 I will not be able to use it. I will award the points an soon as the correct answer is submited to me.
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
double sale[12];
double average,sum=0;
for(int i=0;i<12;i++)
{
cout<<"enter sale of Month:"<<i+1<<endl;
cin>>sale[i];
sum+=sale[i];
}
average=sum/12;
for(int i=0;i<12;i++)
{
if(sale[i]>average)
cout<<"Sales Amount for month "<<i+1<<" is: "<<sale[i]<<" "<<"Sale is higher than average"<<endl;
else
cout<<"Sales Amount for month"<<i+1<<" is: "<<sale[i]<<" "<<"Sale is lower than average"<<endl;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.