The issues I am working on trying to solve:
Taking the input from the "temp" int variables, sending it to the proper conversion method, and having the converted temperature sent back to the screen.
Not having the "Invalid type, please type Celsius or Fahrenheit" line execute when I type exit.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string input = "";
Console.WriteLine("Please enter a conversion type: ");
while (input.ToLower() != "exit")
{
input = Console.ReadLine();
Console.Write("\n");
if (input == "fahrenheit".ToLower())
{
Console.WriteLine("Fahrenheit it is!, Please enter a temperature to convert: ");
int temp;
temp = int.Parse(Console.ReadLine();
//temp = ToFahrenheit();
}
if (input == "celsius".ToLower())
{
Console.WriteLine("Celsius it is!, Please enter a temperature to convert: ");
int temp;
temp = int.Parse(Console.ReadLine());
//temp = ToCelsius();
}
if ((input != "celsius".ToLower()) && (input != "fahrenheit".ToLower()))
{
Console.WriteLine("Invalid type, please type Celsius or Fahrenheit\n");
}
}
}
static string ToFahrenheit(string fTemp)
{
int fahrenheit;
fahrenheit = int.Parse(fTemp);
fahrenheit = fahrenheit * 9;
fahrenheit = fahrenheit / 5;
fahrenheit = fahrenheit + 32;
Console.WriteLine(fahrenheit);
return fTemp;
}
static string ToCelsius(string cTemp)
{
int celsius;
celsius = int.Parse(cTemp);
celsius = celsius - 32;
celsius = celsius * 9;
celsius = celsius / 5;
Console.WriteLine(celsius);
return cTemp;
}
}
}
There are probably some rookie mistakes/obvious mistakes that I am too tired to notice right now, as in I think the Console.Writline(celsius/fahenheit) lines will not work as the value is returned afterwards, or w/e. But help would be appreciated.