In: Computer Science
Using C#
Create a class named Inches To Feet. Its Main()method holds an integer variable named inches to which you will assign a value. Create a method to which you pass inches. The method displays inches in feet and inches. For example, 67 inches is 5 feet 7 inches.
Code:
using System;
class inches
{
static void InchesToFeet(int inch)
{
int
feet,remainInch;
feet=inch/12; //feets calculation
remainInch=inch%12; //remaing Inches after feet
Console.WriteLine(inch+" inches is:"+feet+" Feet "+remainInch+"
inches"); //printing inches in feet and inches
}
static void Main()
{
int inches;
Console.WriteLine("Enter the inches
to convert into feet:"); //input the inches from
user
inches=Convert.ToInt32(Console.ReadLine());
InchesToFeet(inches); //calling
InchesToFeet function
}
}
Output: