# FAQ: Working with Numbers - Review

This community-built FAQ covers the “Review” exercise from the lesson “Working with Numbers”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn C#

## FAQs on the exercise Review

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

## Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Taking the example of calculating compound interest, how would you write something clean that would compound for X-amount of years? If it were able to calculate based on user input for X-years would be nice, but I can’t wrap my head around it at the moment. The code I have written so far is as follows:

double baseSavings = 2000.67;
Console.WriteLine (baseSavings);
double interestRate = 0.11;
Console.WriteLine (interestRate);
double firstYearInterest = (baseSavings * interestRate);
Console.WriteLine (firstYearInterest);
double firstYearTotal = (baseSavings + firstYearInterest);
Console.WriteLine (firstYearTotal);

I’ve written a basic spending tracker program as follows:

// List of monthly outgoings
decimal outContactLenses = 25;
decimal outPetrol = 50;
decimal outMortgage = 538;
decimal outCouncilTax = 112;
decimal outUtilities = 55;
decimal outPhones = 10 + 10;
decimal outWater = 42;
decimal outInsurance = 54 + 10 + 16;
decimal outFood = 200;

``````  decimal outTotal = (outBroadband + outContactLenses + outPetrol + outMortgage + outCouncilTax + outUtilities + outPhones + outWater + outInsurance + outFood);

decimal monthlyPay = 1621;

decimal NDI = (monthlyPay - outTotal);

// Calculations
Console.WriteLine(\$"Monthly pay = £{monthlyPay}");
Console.WriteLine(\$"Total outgoings = £{outTotal}");

Console.WriteLine(\$"Net monthly disposal income = £{NDI}");
``````

Is there a way to program so it automatically adds all of the ‘decimal outXs’ together without having to list each individual one (i.e. ‘decimal outTotal = (outBroadband + outContactLenses, etc.’).

Thanks!

Hi I am sort of stuck on this exercise.
I wrote a program that ask the user for there age and then tells the what age they are in dog years.

``````        int dogYears = 7;

Console.WriteLine("Your age in dog is " + userAge * dogYears);
``````

I know my code works as I ran it in visual studio, but when I try runing it in Codecademy I get the fallowing errors.

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: s
at System.Int32.Parse(String s)
at Review.Program.Main(String args) in /home/ccuser/workspace/csharp-working-with-numbers-review-working-with-numbers-csharp/Program.cs:line 21

can any one help?

Hi guys can some one look below and tell me why the netPay won’t show after (“My Pay Before tax is”

int netPay = 12500;
double vat = 0.20;

``````		double totalTax = netPay * vat;
double grossPay = netPay - totalTax;
Console.WriteLine("My Pay Before tax is", netPay);
Console.WriteLine(totalTax);
Console.WriteLine(grossPay);``````

Hello, @method5217209232. Welcome to the forum.

There are a couple of ways to include the value of your variable, `netPay`, in your output. I’m not sure which of these you may be more familiar with, but here are a few examples to consider:

``````string myString = "wild grapes";
//concatenation:
Console.WriteLine("I like bananas, coconuts and " + myString + "!");
//or composite formatting:
Console.WriteLine("I like bananas, coconuts and {0}!", myString);
``````

Output:

I like bananas, coconuts and wild grapes!
I like bananas, coconuts and wild grapes!

The `{0}` acts as a placeholder for the variable. If you wanted to include values from multiple variables, you just add more placeholders:

``````string item1 = "bananas";
string item2 = "coconuts";
string item3 = "wild grapes";
Console.WriteLine("I like {0}, {1} and {2}!", item1, item2, item3);
``````

Output:

I like bananas, coconuts and wild grapes!

There is also `string interpolation`:

``````string item1 = "bananas";
string item2 = "coconuts";
string item3 = "wild grapes";
Console.WriteLine(\$"I like {item1}, {item2} and {item3}!");
``````

Output:

I like bananas, coconuts and wild grapes!

Happy coding!