Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that converts distance values. The program should give the user

ID: 3604924 • Letter: W

Question

Write a program that converts distance values. The program should give the user three options: convert a whole number of inches to feet and inches, convert feet and inches to decimal feet, or feet and inches to inches. Write the decimal feet to three decimal places. For example, 80 inches is 6 feet, 8 inches; 5 feet, 6 inches is 5.5 feet, and 4 feet, 2 inches is 50 inches. An example of output is provided below: "C:Documents and Settings ClaraWy Documents 1 Teaching LES 115 Computer Application...D Chapter 3 Problen 41 ha onoordfeetland berhof to inche. would you 1se to do? . Convert whole nunber of inches to feet and inches 2. Convert feet and nchee to decinal feet 3. Convert feet and inches to inches 4. Exit Enter 1. 2. 3. or 4-1 Enter total inehes 8O 80 inches is equal to 6 Feet 8 inches 1 equa hat would you like to do? Convert whole nunber oF inches to Feet and inches . Convert Feet and inches to decinal Feet 3. Convort Foot and inchos to inches Exit Entor 1.2.3. 1

Explanation / Answer

C# code follows

--------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class conversion
{
public static string inchesValue, feetValue;
static void Main(string[] args)
{
Console.WriteLine(" Chapter 3 - Problem 41");
Console.WriteLine("");
mainMenu();

}

public static void mainMenu()
{

  
Console.WriteLine("What would you like to do? ");
Console.WriteLine("1.Convert the whole number of inches to feet and inches");
Console.WriteLine("2.Convert feet and inches to decimal feet.");
Console.WriteLine("3.Convert feet and inches to inches.");
Console.WriteLine("4.Exit.");
Console.WriteLine("");
Console.Write("Enter 1,2,3 or 4 --> ");
string userChoice = Console.ReadLine();
switch (userChoice)
{
case "1":
Console.Write("Enter total inches(such as 60)--> ");
inchesValue = Console.ReadLine();
int feetResultValue1 = Convert.ToInt32(inchesValue) / 12;
int inchesLeftResultValue = Convert.ToInt32(inchesValue) % 12;
Console.WriteLine("{0} inches is equal to {1} Feet and {2} Inches", inchesValue, feetResultValue1, inchesLeftResultValue);
Console.WriteLine("");
mainMenu();
return;
case "2":
Console.Write("Enter feet --> ");
feetValue = Console.ReadLine();
Console.Write("Enter inches --> ");
inchesValue = Console.ReadLine();
decimal feetResultValue2 = Convert.ToDecimal(feetValue) + (Convert.ToDecimal(inchesValue) / 12);
Console.WriteLine("{0} feet and {1} inches is equal to {2} feet ",feetValue,inchesValue, feetResultValue2);
Console.WriteLine("");
mainMenu();
return;
case "3":
Console.Write("Enter feet --> ");
feetValue = Console.ReadLine();
Console.Write("Enter inches --> ");
inchesValue = Console.ReadLine();
Console.WriteLine("");
decimal feetResultValue3 = (Convert.ToInt32(feetValue)*12) + Convert.ToInt32(inchesValue) ;
Console.WriteLine("{0} feet and {1} inches is equal to {2} inches ", feetValue, inchesValue, feetResultValue3);
Console.WriteLine("");
mainMenu();
return;
case "4":
Environment.Exit(0);
break;
default:
Console.WriteLine("Wrong entry !!!!");
Console.WriteLine("");
mainMenu();
break;


}


}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote