Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C# SAMPLE CODE: using System; using System.Collections.Generic; using System.Lin

ID: 3725152 • Letter: C

Question

C# SAMPLE CODE:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SimpleTempConversion {
/* Class to convert Celsius temperature to Fahrenheit
* Author ....
* Date: July 2015
*/
class CelsiusToFahrenheit {
public static void Main() {
double celsius = 0.0;
  
//input the temperature in degrees Celsius
Console.Write("Enter degrees Celsius: ");
celsius = int.Parse(Console.ReadLine());

// Calculate degrees Fahrenheit and output the result
Console.WriteLine(" The equivalent in Fahrenheit is " + celsius/5 * 9 + 32);

Console.WriteLine(" Hit Enter to exit.");
Console.ReadLine();
}
}
}

The source code for the program is given below. It is a simple program that takes a temperature in degrees Celsius from the user and displays the same temperature in degrees Fahrenheit; the reverse of a program you wrote for last week's AMS exercises The code contains no input validation. The only requirement is that, if you enter a valid number, it should display the correct converted temperature This is an example of what the program should do when you run it: nter degrees Celsius 100 he equivalent in Fahrenheit is 212 Hit Enter to exit

Explanation / Answer

Hi

I have fixed the issue and highlighted the code changes below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SimpleTempConversion {
/* Class to convert Celsius temperature to Fahrenheit
* Author ....
* Date: July 2015
*/
class CelsiusToFahrenheit {
public static void Main() {
double celsius = 0.0;
  
//input the temperature in degrees Celsius
Console.Write("Enter degrees Celsius: ");
celsius = int.Parse(Console.ReadLine());

// Calculate degrees Fahrenheit and output the result
Console.WriteLine(" The equivalent in Fahrenheit is " + (celsius/5 * 9 + 32));

Console.WriteLine(" Hit Enter to exit.");
Console.ReadLine();
}
}
}

Output: