Process the Input

Look at System.Console.Write code.

Writeis the name of method.

Consoleis the name of the class that the method Writeis contained in.

Systemis the name of namespace that the class Console is contained in.

The purpose of namespace is so we can potentially have multiple classes with the same name.

So far, our code looks like this.

namespace ConsoleApp1
{
    class Program
    {
        static void Main()
        {
            string entry;

            // Prompt the for minutes exercised
            System.Console.Write("Enter how many minutes you exercised");
            entry = System.Console.ReadLine(); 

            // Add minutes exercised to a running total
            // Display the running total in minutes
            // Ask repeatedly until user quits
        }
    }
}

We can simply it into:

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main()
        {
            string entry;

            // Prompt the for minutes exercised
            Console.Write("Enter how many minutes you exercised");
            entry = Console.ReadLine(); 

            // Add minutes exercised to a running total
            // Display the running total in minutes
            // Ask repeatedly until user quits
        }
    }
}

Now, let's continue our code.

We want to simply display user's input to console.

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main()
        {
            string entry;

            // Prompt the for minutes exercised
            Console.Write("Enter how many minutes you exercised: ");
            entry = Console.ReadLine(); 

            // Add minutes exercised to a running total
            // Display the running total in minutes
            Console.Write("You entered " + entry + " minutes");

            // Ask repeatedly until user quits
        }
    }
}

results matching ""

    No results matching ""