Whats wrong with my code?

Can anyone spot check my code for any issues? The question is as follows:

You have a summer job that pays $15.50/hr, the total tax you pay on your total income at the end of the summer is 14%. After you pay taxes you spend 10% on new cloths, then 1% of whats left from that on school supplies. After that you think about investing in savings bonds:

- If you invest nothing into savings bonds then your parents decide to invest 1% of the money you made after taxes, clothes, and school supplies for you. How much did they invest?

- If you invest up to 25% of your net income, your parents invest $0.25 for every dollar you invest PLUS 1% of the money you save after taxes, clothes, and school supplies. How much did they invest?

- If you more than 25% of your net income, your parents invest $0.40 for every dollar you invest PLUS 2% of the money you save after taxes, clothes, and school supplies. How much did they invest?


And here's my code:

#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main()
{
const double hourlyrate;
const double numofhrs;
double pay;
double pat; //pay after taxes
double paca; //pay after taxes and clothes & accessories
double pass; /pay after school supplies

const double sba; //savings bond answer
double sbfp; //savings bonds from parents
double bonussbfp; //bonus from your parents to savings bonds invested


cout << "Enter your hourly rate: ";
cin >> hourlyrate; //$15.50
cout << endl;

cout << "Enter your number of hours worked: ";
cin >> numofhrs;
cout << endl;

hourlyrate * numofhours = pay //pay before taxes
pay - (pay * 0.14) = pat //pay after taxes are taken out
pat - (pat * 0.10) = paca //pay after taxes and clothes & accessories
paca - (paca * 0.01) = pass //pay after taxes,clothes, and school supplies


cout << "How much did you invest on savings bonds after taxes? ";
cin >> sba;


if (sba == 0)
sbfp = pass * 0.01 //Amount invested by parents for savings bonds after you pay for taxes, clothes, and school supplies (1%) .

cout << "Looks like your parents invested 1% of your savings for you! They invested = " << sbfp << endl;

else if (sba <= pat * 0.25)
sbfp = (sba * 0.25) + sba //Amount invested by parents for savings bonds ($0.25 for every $1 invested).
bonussbfp = sbfp + (pass * 0.01) //Amount invested by parents for 1% of every dollar invested after taxes, clothes, and school supplies.

cout << "Looks like your parents invested $0.25 for every dollar of your money you put into savings bonds for you! They invested = " << sbfp << endl;
cout << "They also added 1% of your money after taxes, clothes, and school supplies to your invested! They invested a total of = " << bonussbfp << endl;

else
sbfp = (sba * 0.40) +sba //Amount invested by parents for savings bonds ($0.40 for every $1 invested).
bonussbfp = sbfp + (pass *0.02) //Amount invested by parents for + $2 for every dollar invested after taxes, clothes, and school supplies.

cout << "Looks like your parents invested $0.40 for every dollar of your money you put into savings bonds for you! They invested = " << sbfp << endl;
cout << "They also added 2% of your money after taxes, clothes, and school supplies to your invested! They invested a total of = " << bonussbfp << endl;

return 0;
}

Constant variables need to be initialized with a value.
1
2
3
const double hourlyrate;
const double numofhrs;
const double sba;	


Comments need //
double pass; /pay after school supplies

If you want multiple statements to run together in the if/else blocks, you need to enclose them in { }.
e.g.
1
2
3
4
5
if (condition)
{
do this
do that
}



You're missing some semicolons at the end of statements.


Using the code tags (the <> button at the right side of the post) will make it easier for people to read your code and offer help :)
Last edited on
Thanks a bunch for the help!
Topic archived. No new replies allowed.