Reputation: 1
I have a problem with my homework for my C# class. I need to use different methods to convert inches to feet, yards and miles.
I have come up with some code and it allows me to input inches but does not output anything different from my input. I am new to coding so this has been very frustrating.
using System;
namespace Lesson4
{
class Program
{
static void Main(string[]args)
{
Console.Write("Please input inches:");
string inches = Console.ReadLine();
double feet = ConvertInchesToFeet(int.Parse(inches));
double yard = ConvertInchesToYards(int.Parse(inches));
double miles = ConvertInchesToMiles(int.Parse(inches));
Console.WriteLine(inches);
}
public static double ConvertInchesToFeet(int inches)
{
return inches* 12;
}
public static double ConvertInchesToYards(int yards)
{
return yards* 36;
}
public static double ConvertInchesToMiles(int miles)
{
return miles * 63360;
}
}
}
I am seeking to learn and any help would be greatly appreciated. Thank you in advance.
Upvotes: 0
Views: 40
Reputation: 2518
Welcome to Stackoverflow.
The problem there is that you never assign any new value to inches
but you assign your methods' result to feet
, yard
, miles
.
Try to output those variables:
...
Console.WriteLine(inches);
Console.WriteLine("In feet: " + feet.ToString());
Console.WriteLine("In yard : " + yard .ToString());
Console.WriteLine("In miles : " + miles .ToString());
Upvotes: 1