Tuesday, March 18, 2014

LoopStructure_Ex_2 (Wk 6) Feb 14, 2014

Ex 2: Running on a particular treadmill, you burn 3.9 calories per minute. Write a program that uses a loop (for loop or while loop) to display the number of calories burned after 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 and 60 minutes.
        static void Main(string[] args)
        {
            for (int minute = 10; minute <= 60; minute+=5)
            {
                Console.WriteLine("{0,-3} minutes | {1:f2} burn calories", minute, 3.9 * minute);
            }
            Console.ReadLine();
        }

No comments:

Post a Comment