### Need help on calculations with variables

Hi I have only been learning C++ for a couple of weeks I need help on doing calculations with variables.

It is an exercise I have been given in class and I am now working on at home but I am not outputting the correct answers.

The question is:

A student is allocating his allowance for the 16 weeks of a course over the following areas:

Accommodation - total amount

Materials - one off payment

Food - 60% of remaining allowance

Entertainment - 40% of remaining allowance

Output a breakdown of the availiable money for the student ensuring that the food and entertainment is expressed as a weekly value.

I am getting the correct answer for the total amount for the accomadation but not for the remaining allowance for the Food & Entertainment. Here is the code I have.

 ``12345678910111213141516171819202122232425262728293031323334353637`` ``````#include "stdafx.h" #include #include #include using namespace std; int _tmain(int argc, _TCHAR* argv[]) { double StuAllow, AccWeeklyCost, MatCost, TtlCostAcc, Deducs, RemainAllow, FoodAll, EntAll, WeeklyEntAll, WeeklyFoodAll; double const FoodPerc = 0.6, EntPerc = 0.4; double const LengOfCourse = 16; cout << "\n\n\t\t\t\tStudent Weekly Allowance"; cout << "\n\n\n\tPlease enter the amount of money that you have availiable: "; cin >> StuAllow; cout << "\n\n\tPlease enter the cost of the accomadation per week: "; cin >> AccWeeklyCost; cout << "\n\n\tPlease enter the cost of the materials required: "; cin >> MatCost; TtlCostAcc = AccWeeklyCost * LengOfCourse; Deducs = TtlCostAcc + MatCost; RemainAllow = StuAllow - Deducs; FoodAll = RemainAllow * FoodPerc; WeeklyFoodAll = FoodAll / LengOfCourse; EntAll = RemainAllow * EntPerc; WeeklyEntAll = EntAll / LengOfCourse; cout << "\n\n\tYour total cost for your accomadation will be " << TtlCostAcc; cout << "\n\n\tYour weekly allowance for food will be " << WeeklyEntAll; cout << "\n\n\tYour weekly allowance for entertainment will be " << WeeklyEntAll; cout << "\n\n\tPress any key to end the program."; _getche(); return 0; }``````
Looks like a copy/paste error? Lines 31 and 32 are both printing WeeklyEntAll. I think line 31 was supposed to be printing WeeklyFoodAll.
Thank you very much, silly mistakes are never good!
Topic archived. No new replies allowed.