homework11-godara

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

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

View Full Document Right Arrow Icon
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;
Background image of page 1

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

View Full DocumentRight Arrow Icon
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: "
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online