In: Computer Science
Write a program in c# that declare a variable and store user name jjohn in. Then, write a statement that will make your program display at the screen the content of that variable, followed by " I would like to know your height in centimeter. Please enter it:". Then, write a statement that will store the value entered by the user, allowing decimal numbers ie
some precision, a fraction part. Finally, write statements (more than one can be needed) so that the content of the variable holding your name jjohn, followed by computed that your height is: and the height of user in feet and inches (both as whole numbers, not rounded but trancated) will be diplayed
using System;
class Conversion {
static void Main() {
/* A variable name of type string is declared and stored value
jjohn in it */
string name = "jjohn";
/* Prompting on the console his height in centimeter */
System.Console.WriteLine(name + ", I would like to know
your height in centimeter. Please enter it:");
/* heightInCM is a double variable to accept decimal value from the
user */
/* Console.ReadLine() reads height as a string */
/* and Double.Parse converts that to double value */
double heightInCM =
Double.Parse(Console.ReadLine());
/* convert height in centimeter into inches and feet */
double heightInInches = 0.3937 * heightInCM;
double heightInFeet = 0.0328 * heightInCM;
/* Console.Write is used to print the output on the console
*/
/* Math.Truncate truncates the decimal value in the result */
Console.Write(name + ", computed that your height is: "+
Math.Truncate(heightInFeet) + " feet ");
Console.WriteLine("and "+ Math.Truncate(heightInInches) + "
inches.");
}
}
============================================================================================