Just a little background. This is my first programming course so I'm a complete newbie. This was an assignment that was due 3 days ago so it doesn't matter anymore, grade-wise. Anyway, the problem that I'm running into is that the compiler skips to the end when I put my initials in //User input > "Initials"
I'm using Microsoft Visual C++ 2010 Express.
Here is the assignment:
Plan and code a program to do the following. You found an exciting summer job for 5 weeks. It pays $15.50 per hour. You will input the number of hours per week that you worked and then compute your total earnings. You must pay taxes of 14%. After paying taxes, you will spend 20% of your money on cloths and 5% on school supplies. After buying clothes and supplies, you will use 25% of the remaining money for savings.
Input
Your 3 initials and the hours for each of the 5 weeks. Use the following numbers of hours for your first test 25, 30, 20, 23, 22.
Calculations
Gross pay is the rate of pay times the sum of all hours you worked. Use CONSTANTS for each of the following rates:
Tax rate 14% of the gross earnings
Clothing 20% of earnings after taxes
School supplies 5% of earnings after taxes
Savings 25% of earnings after taxes and expenses
Output
Output your initials, total hours worked, gross earnings, taxes, net earnings after taxes, clothing expense, supplies expense, amount going to savings and amount left to spend. Output must be aligned to the right as shown with 2 decimals in all numbers. Sample output:
Initials ABC
Total Hours Worked 120.00
Gross Earnings 1860
Taxes paid 260.40
Net Earnings 1599.60
Expenses
Cloths 319.92
School Supplies 79.98
Amount Remaining 1199.70
Savings 299.92
Amount left to spend 899.77
Turn in
Be sure your output file contains user prompts and what was entered by the user. In addition to the results of your program processing. Run with above listed data.
Here is my code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double Initials, TotalHours, GrossEarn, TaxesPaid;
double NetEarn, Expenses, ClothAmount, SchoolAmount;
double AmountRem, Savings, AmountLeft, PayRate;
const double TAX_RATE = 0.14;
const double CLOTH_AMT_SPENT = 0.20;
const double SCHOOL_AMT_SPENT = 0.05;
const double SAVINGS_PERCENT = 0.25;
// User input
cout << "Initials: ";
cin >> Initials;
cout << "How many hours did you work: ";
cin >> TotalHours;
cout << "What is the hourly rate: $";
cin >> PayRate;
// Decimal placement
cout << fixed << showpoint << setprecision(2);
// Calculations
GrossEarn = TotalHours * PayRate;
TaxesPaid = GrossEarn * TAX_RATE;
NetEarn = GrossEarn - TAX_RATE;
ClothAmount = NetEarn * CLOTH_AMT_SPENT;
SchoolAmount = NetEarn * SCHOOL_AMT_SPENT;
AmountRem = NetEarn - SCHOOL_AMT_SPENT - CLOTH_AMT_SPENT;
Savings = AmountRem * SAVINGS_PERCENT;
AmountLeft = AmountRem - Savings;
// Output
cout << "Total Hours Worked " << TotalHours << endl;
cout << "Gross Earnings " << GrossEarn << endl << endl;
cout << "Taxes Paid " << TaxesPaid << endl;
cout << "Net Earnings " << NetEarn << endl << endl;
cout << "Expenses" << endl;
cout << "Clothes " << ClothAmount << endl;
cout << "School Supplies " << SchoolAmount << endl << endl;
cout << "Amount Remaining " << AmountRem << endl;
cout << "Savings " << Savings << endl << endl;
cout << "Amount left to spend " << AmountLeft << endl;
system("pause");
}
|