Input: The input file has the needed data on a single line. There is text as well as the numerical inputs. One sample input line is
Pay rate: $15.50 per hour. Weekly hours worked: 25 17.5 30 35.75 32 A second example of an input line is
Pay rate: $12 Hours worked each week: 40 38 30.5 27.5 39
So, the text can vary, but you can count on (1) a dollar sign ($) appears just before the value of pay per hour, (2) a colon (:) appears just before the five values for the number of hours worked each week, and (3) the hours worked values are separated by spaces.
Your program must be able to handle ANY input line that meets these specifications. (You cannot have a different version of the program for each input line.)
Output: The output file will have a table with 2 columns. The left column has the labels telling what each value is; labels are left-justified. The right column has the money value, with 2 decimal places. There is a dollar sign ($) to the left; the money amounts line up on the right (right-justified) so all the decimal points line up vertically.
A sample output follows. (The values are for $15 per hour, and 40 hours worked each week.)
Summer Job Income $ 3000.00
Taxes $ 420.00
Income After Taxes $ 2580.00
Clothes and Accessories $ 258.00
School Supplies $ 25.80
Remaining Money $ 2296.20
Amount Spent on Savings Bonds Amount $ 574.05
Parents Spend on Bonds $ 287.03
The questions asks to use file input/output statements and I have no idea how to write this.
Here's what I got so far:
#include <iostream>
#include <fstream>
using namespace std;
int main (){
ifstream infile("\\psf\Home\Desktop\COSC_Assignments_Windows\EmployeeSalary.txt");
double payRate; //used to hold given pay rate
double firstNumber; //used to hold first hours worked
double secondNumber; //used to hold second hours worked
double thirdNumber; //used to hold third hours worked
double fourthNumber; //used to hold fourth hours worked
double fifthNumber; //used to hold fifth hours worked
infile.get
or
infile.ignore???
Not sure how to read the data then store it into the variables created...? Any pointers?