homework11

# Homework11 - ECE 1574 Homework Set#11 Problem Solving with C Due date Sunday by 11:55 p.m This assignment is to be done individually Work the

This preview shows pages 1–2. 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 <fstream> using std::cout; using std::endl; using std::ifstream; int main() { ifstream is ( "data.txt" ); char lastname[100]; char firstname[100]; double rate; int hours; double sumregular = 0, overtimesum = 0, grosssum = 0; cout << "Name\t\tRate\tHours\tRegular Pay\tOvertime Pay\tGross Pay" << endl; while ( is >> lastname >> firstname >> rate >> hours ){ cout << lastname << " " << firstname << "\t" << rate << "\t" << hours; double regularPay, overtimePay, grossPay; if ( hours <= 40 ){ regularPay = hours * rate; hours = 0; } else { regularPay = 40 * rate; hours = hours - 40; } overtimePay = hours * 1.5 * rate; grossPay = overtimePay + regularPay; cout << "\t" << regularPay << "\t\t" << overtimePay << "\t\t" << grossPay << endl; sumregular = sumregular + regularPay; overtimesum = overtimesum + overtimePay;

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/15/2011 for the course ECE 1574 taught by Professor Rpbroadwater during the Spring '08 term at Virginia Tech.

### Page1 / 4

Homework11 - ECE 1574 Homework Set#11 Problem Solving with C Due date Sunday by 11:55 p.m This assignment is to be done individually Work the

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

View Full Document
Ask a homework question - tutors are online