Write c program that find average of two or more salaries

Assignment Help C/C++ Programming
Reference no: EM131308629

Write a C program that calculates and prints the average of two or more salaries entered by the user. The program should first prompt the user to enter the number of salaries to process (make sure: at least 2 salaries must be entered by user! Give an appropriate polite error message of your choice.) . It should then prompt the user for each salary. As each salary is entered, the program should ensure that the salaries entered are in the salary range of zero and above. If the salary is not in that range, an error message should be displayed (as shown below), and the user should be re-prompted for a salary. Any bad salaries entered should not be included

In the average calculation. Once all values are entered, the program should calculate and print the average of all of the positive values entered, rounded off to the nearest whole cent. At the end display a message for the appropriate salary average. This program will feature the if statement as well as programming techniques for data validation. I call it a trap loop. It traps the user into entering valid data.

The dialog with the user could be as follows:

Welcome to the Salary Analyzer.

This program calculates the average of as many

salaries you wish to enter.

First, enter the number of salaries to process: 4

Now enter the 4 salaries to be averaged.

Enter salary #1: 900
Enter salary #2: 800
Enter salary # 3: -200

*** Invalid entry. Salary must be positive. ***

Enter salary #3: 2500
Enter salary #4: 540

The average of the 4 salaries entered is $1185.00

Your salaries are very generous.

Recall: The coral and green text represents the "output" from your program and is shown for clarity only here.

It is not required that your output be in this color. (Do not even attempt to try!). Also note that what the user types in is indicated by the blue area above; Again, for clarity only. A user-friendly message of your choosing should precede the dialog and explain the program as in green above (you should change the first two sentences to personalize it to you). Notice the trap in salary #3. That would repeat continuously until the user enters a correct data value. After the average is displayed, give the final statements based on the following:

If average <= 999.99 display "Your average salaries is low, employees need a raise a raise."

If 1000 <= average < = 1999.99 display "Your average salaries are adequate."

If average >= 2000 display "Your average salaries is very generous."

Also, a trap loop should be used so that at least two salaries are to be entered by the user.

* This program requires variables of type int and float.
* Use printf and scanf statements to first prompt the user for the number of salaries to be processed(don't forget fflush too).
* This program requires loop structure(s) (for, while or do -- your choice).
* The loop requires some a printf and scanf statement to prompt user for a salary.
* The loop also requires a selection structure (if, or if else) statement to check for bad data values.
* The selection structure requires a printf statement to output error message if improper salary.
* The program requires an accumulator to keep track of the sum of good salaries entered.
* Once all salaries are entered, determine average rounded to the nearest whole cent, and then a printf statement to display the average.

Reference no: EM131308629

Questions Cloud

Would the evidence be admissible in trial : Was direct or circumstantial evidence used in the scenario?Was documentary evidence used?If documentary evidence was used, was it primary or secondary evidence?What evidence collection procedures were used in the scenario?
Treasury inflation-protected? security : ?$1 000 TIPS? (Treasury Inflation-Protected? Security) is currently selling for ?$917 and carries a coupon interest rate of 4.29 percent. If you buy this? bond, how much will you receive for your first interest? payment, assuming no interest adjustme..
Overview and history of company : 1. Leadership is the process by which a  person exerts influence over other people and inspires, motivates, and directs their activities to help achieve group or organizational goals.
How many units of product cure would need to be sold : If Chester were to absorb the new labor costs without passing them on in the form of higher prices, how many units of product Cure would need to be sold next round to break even on the product?
Write c program that find average of two or more salaries : Write a C program that calculates and prints the average of two or more salaries entered by the user. The program should first prompt the user to enter the number of salaries to process.
What would her percentage return be in load fund return case : Alex later sells her shares in the mutual fund for $12.50 per share. What would her percentage return be in a load fund return case?
Crimped by recession from bloomberg business : Read the article, Outsourcing Gets Crimped by Recession from Bloomberg Business.  Answer the following questions in your discussion board posting base on this article:
Which market imperfections would be most relevant : If Intel were to increase its debt by $1 billion and use the cash for a share repurchase, which market imperfections would be most relevant for understanding the consequence for Intel's value? Why?
What will be the annual net savings : No more Books financial management expects that collections will be accelerated by 1 day if the eastern region is divided. Should the company proceed with the new system? What will be the annual net savings? Assume that the T-bill is 5 percent ann..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write function to find whether number is perfect number

Write down the function perfect which determines whether number is perfect number or not. This function must receive number and return true if number is perfect.

  Method to generate the random numbers

Write a program that will generate a set of 75 random integers in the range -26 to + 42. The program should display the following:

  Two dimensional int array to hold the prices of the seats

The Theater class shows a theater with an auditorium containing a fixed number of seats arranged in rows with each seat selling for a exacting price. The instance variables for the theater are:

  Write a program that finds the biggest digit of the x

Program then finds the biggest digit of the x by using biggestDigit function (c). And prints all the prime numbers from 0 to 100 using isPrime function (b).

  Determines and displays what the amount of his gross pay

Write a program that determines and displays what the amount of his gross pay will be for each pay period if he is paid twice a month (24 pay checks per year) and if he paid bi-weekly.

  Recursive function

What is the result of the following recursive function when called with mm(10)? Write out the execution trace of this call to mm(10).

  Explain the data types used in c language

What is data type? Explain the data types used in C language.Write a program and draw a flowchart to print 1 to 100 all natural numbers.

  Winning number combinations from the missouri lottery

The file input.txt contains all of the winning number combinations from the Missouri Lottery since it took its current form on January 3, 1998.  The data is in a file called "input.txt"  All of the data in the file is integer.

  The program calls a function called getgrades

The program calls a function called GetGrades that will read in grades from the keyboard, the number of grades should also be input by the user.

  Calculate the gross pay of a set of employees

Write a C program that will calculate the gross pay of a set of employees - For each employee the program should prompt the user to enter the clock number, wage rate, and number of hours

  Computes the product of all elements in a vector

Write a C function that computes the product of all elements in a vector x of dimension n. The elements of the vector are stored in a double array of size n.

  A perfect solution is impossible or too expensive

Optimization is often encountered in engineering problems. More often than not, a perfect solution is impossible or too expensive to find and implement. Therefore, we resort to sub-optimal, yet useful, solutions. This assignment tackles a classical p..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd