#include <iostream>
using namespace std;

int main()
    const double WEEKS=5;
    const double TAXES=.14;
    const double CLOTHINGEXPENSES=.10;
    const double SUPPLIESEXPENSES=.01;
    const double SAVINGSBONDS=.25;
    const double PSAVINGSBONDS=.50;

//Declaration Section
double hours, rate, taxes, grosspay, netincome, clothingexpenses;
double remainingbalance, savingsbonds, psavingsbonds, suppliesexpenses;
double finaltotal; 

//Input Section
cout.precision(2); //sets the 'double' data type to (2) decimal places
cout<<"Please enter your pay rate"<<endl;
cin>> rate;
cout<<"Please enter the amount of hours worked each week"<<endl;
cin>> hours;

//Compute Section
grosspay= rate * hours;
taxes= grosspay * taxes;
netincome= grosspay - taxes;
clothingexpenses= netincome * clothingexpenses;
suppliesexpenses= netincome * suppliesexpenses;
remainingbalance= netincome - clothingexpenses - suppliesexpenses;
savingsbonds= remainingbalance * savingsbonds;
psavingsbonds= savingsbonds * psavingsbonds;
finaltotal= remainingbalance - savingsbonds;

//Input Section
cout<<"After you have worked, how much you have grossed:"<<grosspay<<endl;
cout<<"                                                 "<<endl;
cout<<"Taxes Withheld:"<<taxes<<endl;
cout<<"                                                 "<<endl;
cout<<"Net Income:"<<netincome<<endl;
cout<<"                                                 "<<endl;
cout<<"Clothing Expense (10.00% of Net Income):"<<clothingexpenses<<endl;
cout<<"                                                 "<<endl; 
cout<<"Supplies Expense (1.00% of Net Income):"<<suppliesexpenses<<endl;
cout<<"                                                 "<<endl;
cout<<"Remaining Balance after Taxes and Expenses:"<<remainingbalance<<endl;
cout<<"                                                 "<<endl;
cout<<"My Savings Bonds Contribution (25.00% of Remaining Balance):"<<savingsbonds<<endl;
cout<<"                                                 "<<endl;
cout<<"Parents Savings Bonds Contribution ($0.50 for each dollar I spent on Savings Bonds):"<<psavingsbonds<<endl;
cout<<"                                                 "<<endl;
cout<<"Final Total after taxes, expenses and savings..."<<finaltotal<<endl;

return 0;

}//end of the function main

I dont know what the problem is. My calculation are correct and everything, but when i run the program and enter the payrate it goes through. Then i enter the amount of hours worked, it goes through, but after that it does the calculations and goes away. Can someone please copy and paste this program to their dev-c++ to see what I'm talking about. This is very frustrating and it is very important I solve the problem.

8 Years
Discussion Span
Last Post by southernd0529

It was edited for not following the rules.

Your program does nothing but get numbers because it goes:

compute empty values
get input
display input

You probably should keep the values in a struct or something, and do the math in a function. Keeps everything a tad nicer looking.


i figured it out...... My const doubles were put in after the int main instead of before.....HA silly me lol anyway i appreciate all the help...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.