Write a program that computes the quarterly average sales fo

Write a program that computes the quarterly average sales for a salesperson in a department store. Every three months, the store calculates the quarterly average sales for each salesperson. Display the salesperson\'s name and the average. Allow the user to calculate as many salespeople as average as desired. Read the name of the salesperson from the user. Read the sales made by the salesperson from the user for each month during the quarter using a for loop. Display an error message if a negative sale\'s amount is entered and prompt for reentry until it is valid. Compute the average quarterly sales for that salesperson. Display the name of the salesperson and the computed quarterly average. Please enter the salesperson\'s name:? Mary Hill Please enter the sales from each month in the quarter. Month 1 Sales: $ 450.67 Month 2 Sales: $ 500.50 Month 3 Sales: $ 700.25 The quarterly average sales for Mary Hill is $550.47 Would you like to calculate the average for another salesperson? (Y or N) Please enter the salesperson\'s name: ? Joe Morgan Please enter the sales from each month in the quarter. Month 1 Sales: $ 560.00 Month 2 Sales: $ 650.00 Month 3 Sales: $ 825.50 The quarterly average sales for Joe Morgan is $678.50 Would you like to calculate the average for another salesperson? (Y or N)

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

 Write a program that computes the quarterly average sales for a salesperson in a department store. Every three months, the store calculates the quarterly avera
 Write a program that computes the quarterly average sales for a salesperson in a department store. Every three months, the store calculates the quarterly avera

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site