Question

In: Computer Science

Create a class using C# named InchesToFeet. Its Main()method holds an integer variable named inches to...

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.

Solutions

Expert Solution

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!!!!!!!!----------


Related Solutions

Using C# Create a class named Inches To Feet. Its Main()method holds an integer variable named...
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.
Write in C++: create a Doubly Linked List class that holds a struct with an integer...
Write in C++: create a Doubly Linked List class that holds a struct with an integer and a string. It must have append, insert, remove, find, and clear.
Java Programming Create a class named Problem1, and create a main method, the program does the...
Java Programming Create a class named Problem1, and create a main method, the program does the following: - Prompt the user to enter a String named str. - Prompt the user to enter a character named ch. - The program finds the index of the first occurrence of the character ch in str and print it in the format shown below. - If the character ch is found in more than one index in the String str, the program prints...
Write a C++ code for these 2 questions 1. Create an integer variable named ‘arraySize’ and...
Write a C++ code for these 2 questions 1. Create an integer variable named ‘arraySize’ and initialize the value to 1000. 2.. Open an output file named ‘GroupAssignment2Results.csv’. The first line of this file should be the column headings: ‘Array Size’, ‘Bubble Sort Time’, ‘Selection Sort Time’, ’Insertion Sort Time’, ‘Quick Sort Time’, ‘Merge Sort Time’.
In Java Create a class called "TestZoo" that holds your main method. Write the code in...
In Java Create a class called "TestZoo" that holds your main method. Write the code in main to create a number of instances of the objects. Create a number of animals and assign a cage and a diet to each. Use a string to specify the diet. Create a zoo object and populate it with your animals. Declare the Animal object in zoo as Animal[] animal = new Animal[3] and add the animals into this array. Note that this zoo...
Create a PoemDriver.java class with a main method. In the main method, create an ArrayList of...
Create a PoemDriver.java class with a main method. In the main method, create an ArrayList of Poem objects, read in the information from PoemInfo.txt and create Poem objects to populate the ArrayList. After all data from the file is read in and the Poem objects added to the ArrayList- print the contents of the ArrayList. Paste your PoemDriver.java text (CtrlC to copy, CtrlV to paste) into the open space before. You should not change Poem.java or PoemInfo.txt. Watch your time...
In C++ Create a dynamic array of 100 integer values named myNums. Use a pointer variable...
In C++ Create a dynamic array of 100 integer values named myNums. Use a pointer variable (like ptr) which points to this array. Use this pointer variable to initialize the myNums array from 2 to 200 and then display the array elements. Delete the dynamic array myNums at the end. You just need to write part of the program.
Create a class named TestLease whose main() method declares four Lease objects. Call a getData() method...
Create a class named TestLease whose main() method declares four Lease objects. Call a getData() method three times. Within the method, prompt a user for values for each field for a Lease, and return a Lease object to the main() method where it is assigned to one of main()’s Lease objects. Do not prompt the user for values for the fourth Lease object, but let it continue to hold the default values. Then, in main(), pass one of the Lease...
Create an C# application named ConvertMilesToKilometers whose Main() method prompts a user for a number of...
Create an C# application named ConvertMilesToKilometers whose Main() method prompts a user for a number of miles, passes the value to a method that converts the value to kilometers, and then returns the value to the Main() method where it is displayed.
Java Codes: 1. Create a class named Proficiency1Practice In the main method, first ask the user...
Java Codes: 1. Create a class named Proficiency1Practice In the main method, first ask the user to enter a short sentence which ends in a period. Use Java String class methods to determine the following about the sentence and display in the console: • How many total characters are in the sentence? • What is the first word of the sentence? Assume the words are separated by a space. • How many characters are in the first word of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT