How can I create a console-based application whose Main() method
holds an integer variable named inches, and prompt
the user for a value. and to create a method to which I pass
inches. The method converts the value to feet and inches
and displays the result. For example, 67 inches is 5 feet 7
inches. ?

VulpesRank #55 · 29.2K reputationPosted Sep 10, 2014, 2:52 AM EDT
Dipankar BiswasRank #992 · 2K reputationPosted Sep 9, 2014, 11:34 PM EDT
lovlly bersbe17 reputationPosted Sep 9, 2014, 11:58 PM EDT
Dipankar BiswasRank #992 · 2K reputationPosted Sep 10, 2014, 1:16 AM EDT
using System.Collections.Generic;
using System.Text;
class Utilities
{
public string ConvertMetersToFeet(string strMeters)
{
double feet = 0;
double meters = 0;
if (double.TryParse(strMeters, out meters))
feet = meters * 3.2808399;
return feet.ToString();
}
}
http://www.java2s.com/Code/CSharp/Development-Class/ConvertMetersToInches.htm
Abhishek KumarRank #510 · 4.8K reputationPosted Sep 10, 2014, 2:32 AM EDT
Please find the sample code attached.
Hope this will help you.
Abhishek
lovlly bersbe17 reputationPosted Sep 10, 2014, 8:25 AM EDT
VulpesRank #55 · 29.2K reputationPosted Sep 10, 2014, 8:38 AM EDT
using System;
class Program
{
static void Main()
{
Console.Write("Enter number of inches : ");
int inches = int.Parse(Console.ReadLine());
InchesToFeet(inches);
InchesToYards(inches);
Console.ReadKey();
}
static void InchesToFeet(int inches)
{
int feet = inches / 12;
int inches2 = inches % 12;
string inchStr = (inches == 1) ? "inch" :"inches";
string footStr = (feet == 1) ? "foot" : "feet";
string inchStr2 = (inches2 == 1) ? "inch" :"inches";
Console.WriteLine("{0} {1} is {2} {3} {4} {5}", inches, inchStr, feet, footStr, inches2, inchStr2);
}
static void InchesToYards(int inches)
{
int feet = inches / 12;
int inches2 = inches % 12;
int yards = feet / 3;
feet = feet % 3;
string inchStr = (inches == 1) ? "inch" :"inches";
string footStr = (feet == 1) ? "foot" : "feet";
string inchStr2 = (inches2 == 1) ? "inch" :"inches";
string yardStr = (yards == 1) ? "yard" : "yards";
Console.WriteLine("{0} {1} is {2} {3} {4} {5} {6} {7}", inches, inchStr, yards, yardStr, feet, footStr, inches2, inchStr2);
}
}
lovlly bersbe17 reputationPosted Sep 12, 2014, 7:29 PM EDT
VulpesRank #55 · 29.2K reputationPosted Sep 14, 2014, 6:50 AM EDT
// add 'skeleton' handler by double-clicking button in VS designer