Write a program that computes the quarterly average sales fo
Solution
// header files for our program to use defined function
#include<stdio.h>
 #include<conio.h>
 #include<iostream.h>
 void main()
 {
 clrscr(); // function used for clear console screen
 char ch; // for checking yes or no for other salesperson sales average
 char Name[50]; // char type array for Name of salesperson
 float avgsale; // variable to hold average value
float sum=0; // sum for sales value
 float sale;
do
 {
 cout<<\"Enter sales Person Name\"<<endl;
 gets(Name);
 cout<<\"Please enter the sales from each month in the quarter\" <<endl;
 for(int i=1;i<4;i++)
 {
 do // this do while loop for checking sales value postive
 {
 cout<<\"Month:\"<<i<< \" sales\" <<endl;
 cin>> sale;
 }while(sale<0);
sum = sum+sale;
}
 avgsale= sum/3.0;
 cout<<\"The quarterly sales for\\t \"<<Name<<\"is\\t\"<<avgsale<<endl;
 cout<<\"would you like to calculate the average for another salesperson?(Y or N)\"<<endl;
 cin>>ch;
} while(ch==\'Y\' || ch==\'y\');
getch();
}
output:
Enter sales Person Name:
MaryyHill
Please enter the sales from each month in the quarter
Month 1 sales
90
Month 2 sales
30
Month 3 sales
60
The quarterly sales for MarryHill is 60
would you like to calculate the average for another salesperson?(Y or N)
n


