Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Pedro Suarez
Pedro Suarez
993 Points

number to quantity

using System;

class Program { static string Ask(string question) { Console.Write(question + " "); return Console.ReadLine(); }

static double Price(int quantity) { return quantity * 2;


static void Main()
    Console.WriteLine("Welcome to the cat food store!");

    string entry = Ask("How many cans are you ordering?");
    int number = int.Parse(entry);
    double total = Price(number);
    Console.WriteLine($"For {number} cans, your total is: ${total}");


how are we able to pass the number of cans to ( int quantity) if they have different names

1 Answer

Steven Parker
Steven Parker
220,925 Points

The parameter name represents whatever is passed in to the function when it is called. It's effectively like a variable that is assigned to the passed value.