Question

In: Computer Science

Write a program in c# that declare a variable and store user name jjohn in. Then,...

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

Solutions

Expert Solution

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.");
}
}

============================================================================================


Related Solutions

C++ Write a program to declare an array of double of size 25, ask the user...
C++ Write a program to declare an array of double of size 25, ask the user to input all array elements from the keyboard, then write a function named out_of_order that will test this array for the condition a[0] >= a[1] >= a[2] >= ... > a[24] The function returns a -1 if the elements are not out of order, otherwise it returns the index of the first element that is out of order. Explain what you do to avoid...
Tail of a File, C++ Program. write a program that asks the user for the name...
Tail of a File, C++ Program. write a program that asks the user for the name of a text file. The program should display the last 10 lines, or all lines if less than 10. The program should do this using seekg Here is what I have so far. #include<iostream> #include<fstream> #include<string> using namespace std; class File { private:    fstream file;    string name; public:    int countlines();    void printlines(); }; int File::countlines() {    int total =...
1- Write a c++ program that asks the user to enter his/her name using one variable...
1- Write a c++ program that asks the user to enter his/her name using one variable only. The name must be then printed out in capital letter with the family name first and the last name second.
3. Write a C++ program that takes in the name of a store, and the following...
3. Write a C++ program that takes in the name of a store, and the following details for 4 employees working at the store; their first name, last name, number of hours they worked that week and how much they are paid per hour. Your program should output the name of the store, along with each employee's full name and how much they earned that week in the manner below. Monetary values should be format to 2 decimal places. Also...
Declare a string variable and initialize it with your first name ( in C++)
Declare a string variable and initialize it with your first name ( in C++)
Please code in c# (C-Sharp) Write a program that will ask the user for their name....
Please code in c# (C-Sharp) Write a program that will ask the user for their name. If the user does not input anything, display a warning before continuing. The program will then ask the user whether they want to have an addition, subtraction, multiplication, or division problem. Once the user indicates their choice, the program will display 2 randomly generated numbers from 1 to 9 in a math problem matching the user’s choice. Example: user selects addition, the equation presented...
C# Write a program in C# that prompts the user for a name, Social Security number,...
C# Write a program in C# that prompts the user for a name, Social Security number, hourly pay rate, and number of hours worked. In an attractive format, dis- play all the input data as well as the following: » Gross pay, defined as hourly pay rate times hours worked » Federal withholding tax, defined as 15% of the gross pay » State withholding tax, defined as 5% of the gross pay » Net pay, defined as gross pay minus...
C++ : Write a program that creates a login name for a user, given the user's...
C++ : Write a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input. Output the login name, which is made up of the first five letters of the last name, followed by the first letter of the first name, and then the last two digits of the number (use the % operator). If the last name has less than five letters, then use all letters of the...
Write a program using C language that -ask the user to enter their name or any...
Write a program using C language that -ask the user to enter their name or any other string (must be able to handle multiple word strings) - capture the epoch time in seconds and the corresponding nanoseconds - ask the user to type in again what they entered previously - capture the epoch time in seconds and the corresponding nanoseconds -perform the appropriate mathematical calculations to see how long it took in seconds and nanoseconds (should show to 9 decimal...
C++ Bubble Sort Write a program that ask user to enter 7 numbers and store that...
C++ Bubble Sort Write a program that ask user to enter 7 numbers and store that in array. Display that all numbers before and after performing Bubble sort. You must have to create new function with required parameter to perform Bubble sort. Sample Run :- Enter 1 number :- 1 Enter 2 number :- 5 Enter 3 number :- 7 Enter 4 number :- 45 Enter 5 number :- 90 Enter 6 number :- 6 Enter 7 number :- 55...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT