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

  How to implement member functions in c++

I am having a dificult time understanding Classes in C++ and how to implement member functions. Given the attached code I need to:

  Write a c function for reversing circular single linked list

Let A and B be two structures of type linked list. Write a function for creating new linked list C that contains elements alternately from A and B beginning with first element of A. If you run out of the elements in one of the lists then append the r..

  Program to compute the total volume

Write a program to compute the total volume for a number of cylinders. A cylinder may have different values for height and radius.

  Program that will input any four float values

You need to prepare a program to print the given output - write a program that will input any four float values where the four variables are declared in the 'main' function and perform

  Reading of coefficients

Reading of coefficients a, b, c shall be done by a function named readCoeffs(). They shall be entered as double's from the keyboard by an operator, after prompt, as follows.

  Practice with c functions

This homework will give you practice with C++ functions as well as string manipulation.

  Write a printf or scanf statement

Write a printf or scanf statement for each of the following:a. Print unsigned integer 40000 left justified in a 15-digit field with 8 digits.b. Read a hexadecimal value into variable hex.

  Design a system using a class called books

Design a system using a class called Books with suitable members

  Write a c++ program that prompts the user for a double

Write a C++ program that prompts the user for a double that is either positive or negative.

  Write an lc-3 machine language program

Write an LC-3 machine language program starting at location x3000 which divides the number in memory location x4000 by the number in memory location x4001 and stores the quotient at x5000 and the remainder at x5001.

  Write a program to make the ssds function

Write a program to make the SSDs function as a MM:SS real-time clock. Hint: You must not use a single delay routine for the one second delay because that will not allow for persistence of vision. The displays need to be constantly refreshed during ev..

  Develop a time delay procedure

Develop a time delay procedure for the 2.0 GHz Pentium 4 that waits for 80s.

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