Homework 10 Solution

Homework 10 Solution - E CE 1574 Homework Set #10 P roblem1...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 1574 Homework Set #10 Problem1 #include <iostream> #include <fstream> #include <string> using namespace std; int main () { // writing on a text file ofstream myfile ( "Pay_Details.txt" ); if (myfile.is_open()) { myfile << "Callaway,G. \t 6.00 \t 40 \n" ; myfile << "Hanson,P. \t 5.00 \t 48 \n" ; myfile << "Lasard,D. \t 6.50 \t 35 \n" ; myfile << "Stillman,W. \t 8.00 \t 50 \n" ; myfile.close(); } else cout << "Unable to open file" ; // Read from the created text file to prepare pay report string name; double rate, hrs, regpay, ovrpay, gross, tot_reg = 0, tot_ovr = 0; ifstream myfileread ( "Pay_Details.txt" ) ; cout << "\nName \t\tRate \tHrs \tRegularPay \tOvertimePay \tGrossPay \n" ; cout<< "-------------------------------------------------------------------- ---\n" ; if (myfileread.is_open()) { myfileread >> name >> rate >> hrs; // Read file till the end and perform calculations meanwhile // Over time pay is not zero only if work hours is greater than 40 // Gross pay is always sum of regular and overtime pay
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Homework 10 Solution - E CE 1574 Homework Set #10 P roblem1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online