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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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