Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

EGR 126 Exercise 4 - File Input The objective of this Exercise is to demonstrate the use of a file for data input. Write a

image text in transcribedimage text in transcribed

EGR 126 Exercise 4 - File Input The objective of this Exercise is to demonstrate the use of a file for data input. Write a program for a payroll calculation: given a name, hours worked, and an hourly wage, calculate and print the total amount earned in a sentence. Your output might look something like the following: CH. C:\Windows\system32\cmd.exe Harriette Roadman Exercise 4 Jan 23, 2016 Data is being read from file ex4data.txt File contains: name (single word), hours worked (float), wage (float, in dollars per hour) Samantha worked 24.50 hours at $7.85 per hour and earned $192.32 for the week. Press any key to continue ... This data file was used for input to the program that produced the output shown above: ex4data - Notepad File Edit Format View Help File contains: name (single word), hours worked (float), wage (float, in dollars per hour) Samantha 24.5 7.85 Things to note: Things to note: Please review the documents File Creation and File Input & Output. You will need to create a data file to use for input. You will choose the name of the input file. You might use something like "ex4data.txt". For this Exercise you should set up the input file to contain at least 4 lines of data: First line: information on how the file is set up Second line: a name (either one word, or several words, but must be character data) Third line: a value for hours worked, should be a decimal number Fourth line: a value for hourly wage, no $ included, should be a decimal number Write your code to read the values from the input file, including the first line, calculate the wage, and print the information requested. Your output doesn't need to be identical to what is shown, but it does need to have the same content. The input values are echoed as part of the wage sentence. Be sure to use #include print the file name. include a $ sign in the cout statement for the hourly wage as well as for the total earnings. use cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions