Design an application that converts miles to feet. Declare and initialize miles to 4.5. Show your miles formatted with two positions to the right of the decimal. Feet and inches should both be shown with no positions to the right of the decimal. Once you get that portion running, modify your solution so that you also show the total number of inches. Go into your source code and change the initialization value for miles. Rerun the application.
Solution :
/* Author: Sudhakar
Date: 13/04/2020
Task: Miles to Feet and Inches */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProExercise1
{
class Program
{
static void Main(string[] args)
{
//declaration
double milesLength = 4.5;
double feetLegth;
double inchesLength;
feetLegth = milesLength * 5280; //convertion from miles to feet
inchesLength = milesLength * 5280 * 12; //convertion from miles to inches
//display output
Console.WriteLine("Given Miles : " + "{0:f2}", +milesLength);
Console.WriteLine("Length from Miles to Feet : " + "{0:f0}", +feetLegth);
Console.WriteLine("Length from Miles to Inches : " + "{0:f0}", +inchesLength);
}
}
}
Output :
Given Miles : 4.50
Length from Miles to Feet : 23760
Length from Miles to Inches : 285120