Answer to Question #322549 in C# for Madhu

Question #322549

Menu Driven Temperature Converter


Write a C# program to design menu driven temperature converter console application.

The program should show following options for temperature conversion to user:

  1. Centigrade to Farenheit
  2. Farenheit to Centigrade

The program should then prompt user to enter the temperature value.

The given value should be converted to the required temperature unit, based on the choice inputted by user.


1
Expert's answer
2022-04-02T09:59:10-0400
using System;

namespace Convert_temper
{
    class Program
    {
        public static void Main(string[] args)
        {
            int menu;
            double cels, fahr, temp;
            Console.WriteLine("Options:");
            Console.WriteLine("(1) Centigrade to Farenheit");
            Console.WriteLine("(2) Farenheit to Centigrade");
            Console.Write("\nSelect: ");
            menu = Convert.ToInt32(Console.ReadLine());
            if (menu == 1)
            {
                Console.Write("Enter temperature in Celsius: ");
                temp = Convert.ToDouble(Console.ReadLine());
                fahr = temp * 1.8 + 32;
                Console.WriteLine("Temperature in Fahrenheit = {0:f2}", fahr);
            }
            else if (menu == 2)
            {
                Console.Write("Enter temperature in Fahrenheit: ");
                temp = Convert.ToDouble(Console.ReadLine());
                cels = (temp - 32) * 5 / 9;
                Console.WriteLine("Temperature in Celsius = {0:f2}", cels);
            }
            else
                Console.WriteLine("Invalid selected options");

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

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