Answer to Question #327017 in C# for mandeep

Question #327017


 5. “OptionB” Method 

Create a method called “OptionB” that will print the conversion from miles to kilometres by calling “MilesToKilometers” method (defined in the item #6 below) starting at 10 miles up to 100 miles in increments of 10. Show the result on a table in the console. 

6. “MilesToKilometers” Method 

Create a method called “MilesToKilometers” 

  • Name: MilesToKilometers 
  • • Parameter: o A double representing the miles distance 
  • o A double representing the kilometers distance - this should be an "out" parameter 
  • Returns: Nothing 
  • Displays: Nothing 
  • Task: Calculates the conversion from miles to kilometers. The converted kilometer is returned as an "out" parameter 
1
Expert's answer
2022-04-11T02:07:52-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ComputeAverageApp
{
    class ComputeAverageProgram
    {
        static void Main(string[] args)
        {
            OptionB();
            Console.ReadKey();
        }

        private static void OptionB()
        {
            Console.WriteLine("miles    kilometers");
            for (int mile = 10; mile <= 100; mile += 10)
            {
                double km = 0;
                MilesToKilometers(mile, out km);
                Console.WriteLine("{0, 4}       {1}", mile, km);
            }
        }

        private static void MilesToKilometers(double mlValue, out double kmValue)
        {
            kmValue = mlValue * 1.60934;
        }
    }

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS