homework11-godara

# homework11-godara - ECE 1574 Homework Set#11 Problem...

This preview shows pages 1–3. Sign up to view the full content.

ECE 1574 Homework Set #11 Problem Solving with C++ Due date: Sunday 4/11/10 by 11:55 p.m. This assignment is to be done individually Work the following problems. 1. Problem 1 on page 486 of Bronson. #include <iostream> #include <string> #include <fstream> using namespace std; void main () { ofstream listfile ( "Paylist.txt" ); if (listfile.is_open()) { listfile << "Callaway,G. 6.00 40" << endl; listfile << "Hanson,P. 5.00 48" << endl; listfile << "Lasard,D. 6.50 35" << endl; listfile << "Stillman,W. 8.00 50" << endl; listfile.close(); } else cout << "FILE ERROR" ; double rate, hours, regularpay, overpay, grosspay; double totalregular = 0, totalover = 0; string name; ifstream readit ( "Paylist.txt" ); cout << endl; if (readit.is_open()) { readit >> name >> rate >> hours; while (! readit.eof()) { overpay = 0; if (hours>40) { regularpay = rate * 40.0; overpay = 1.5 * rate * (hours - 40.0); } else regularpay = rate * hours; grosspay = regularpay + overpay;

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

View Full Document
totalregular = totalregular + regularpay; totalover = totalover + overpay; cout << "Pay for: " << name << " Rate: " << rate << " Hours: " << hours << " Regular Pay: " << regularpay << " Overtime: " << overpay << " Gross Pay: " << grosspay << endl; readit >> name >> rate >> hours; } readit.close(); } else cout << "FILE ERROR" ; cout << " Total Regular pay combined: " << totalregular << " Total Overtime combined: "
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/14/2010 for the course COMM 2064 taught by Professor Jimkuypers during the Spring '08 term at Virginia Tech.

### Page1 / 6

homework11-godara - ECE 1574 Homework Set#11 Problem...

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

View Full Document
Ask a homework question - tutors are online