In: Computer Science
Create a class using C# named InchesToFeet. 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 uses 2 ref parameters: feet, inches left of type int and a parameter that is not ref of type int to which you pass inchesinches. For example, 67 inches is 5 feet 7 inches.
SOLUTION-
I have solve the problem in C# code with comments and screenshot
for easy understanding :)
CODE-
//C# code
using System;
//class
class Program
{
static void Main()
{
Console.Write("Enter number of inches : ");
int inches = int.Parse(Console.ReadLine()); //gets input from
user
InchesToFeet(inches);
InchesToYards(inches);
Console.ReadKey();
}
//function to calculate inches to feet
static void InchesToFeet(int inches)
{
//calculates feet 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); //prints
}
//function to calculate inches to yard
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";
//prints
Console.WriteLine("{0} {1} is {2} {3} {4} {5} {6} {7}", inches,
inchStr, yards, yardStr, feet, footStr, inches2, inchStr2);
}
}
SCREENSHOT-
IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I WILL
SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK
YOU!!!!!!!!----------