Make it ASP.NET WebForm application with calculations on the server side. Implem
ID: 3828027 • Letter: M
Question
Make it ASP.NET WebForm application with calculations on the server side. Implement the following functions: a) Function Celsius returns the Celsius equivalent of a Fahrenheit temperature, using the calculation C=5.0/9.0*(F-32 ); b) Function Fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using the calculation F=9.0/5.0*C+32; c) Use these functions to write a script that enables the user to enter either a Fahrenheit or a Celsius temperature and displays the Celsius or Fahrenheit equivalent. Your HTML5 document should contain two buttons - one to convert from Fahrenheit to Celsius and one to convert from Celsius to Fahrenheit. Must use: Use CSS
Explanation / Answer
Ans: The below is the required code:
//using_system
using System;
// collection_generic
using System.Collections.Generic;
// linq
using System.Linq;
using System.Text;
// namespace
namespace _4._4TemperatureConversion
{
class <a href="#">Program</a>
{
public static double <a href="#">Fahrenheit</a>=0;
public static double <a href="#">Celsius</a>=0;
public static int Choice = 0;
static void Main(string[] args)
{
// options
PrintConversionOptions();
// choice
getChoice(Choice);
}
// print_conversion
static void PrintConversionOptions()
{
Console.WriteLine("Please Select What <a href="#">Temperature</a> You Want To <a href="#">Convert</a> To");
Console.WriteLine("(1) <a href="#">Fahrenheit</a>");
Console.WriteLine("(2) <a href="#">Celsius</a>");
}
static void getChoice(int choice)
{
double <a href="#">Celsius</a> = 0;
double <a href="#">Fahrenheit</a> = 0;
// choice_console
choice = int.Parse(Console.ReadLine());
// switch
switch (choice)
{
// case_1
case 1:
Console.WriteLine(" Enter The <a href="#">Celsius</a> You Want To <a href="#">Convert</a>");
<a href="#">Celsius</a> = double.Parse(Console.ReadLine());
if (<a href="#">Celsius</a> > -273)
{
<a href="#">Fahrenheit</a> = (<a href="#">Celsius</a> * 9 / 5) + 32;
Console.WriteLine(" The <a href="#">Fahrenheit</a> is: {0}", <a href="#">Fahrenheit</a>);
}
break;
case 2:
Console.WriteLine(" Enter The <a href="#">Fahrenheit</a> You Want To <a href="#">Convert</a>");
if (<a href="#">Fahrenheit</a> > -459)
{
<a href="#">Fahrenheit</a> = double.Parse(Console.ReadLine());
<a href="#">Celsius</a> = (<a href="#">Fahrenheit</a> - 32) * 5 / 9;
Console.WriteLine(" The <a href="#">Celsius</a> is:{0}", <a href="#">Celsius</a>);
}
// if above 459
if (<a href="#">Fahrenheit</a> < -459)
{
Console.WriteLine(" We do not accept any number below -459 <a href="#">fahrenheit</a>");
}
break;
//default
default:
Console.WriteLine("That is not a valid choice");
break;
}
Console.ReadLine();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.