CSI 1390
Assignment 1
Question 1:
a. Convert the following numbers from binary to decimal.
11011011011, 11101110110
b. Convert the following numbers from decimal to base 2 and base 8
122, 89, 142, 46
Question 2:
Mary and her uncle Sam live in Montreal. 5 Years ago, the age of Sam was 3 times the age of Mary and in 5 years Sam will be twice older than Mary. Write the mathematical formulas which give you the ages of Mary and her uncle Sam. How old is Mary and how old is Sam?
Question 3:
Write a Java program to convert centimeters (input) to feet and inches (output). Use the following: 1 inch = 2.54 centimeters
Question 4:
Write a Java program that prompts you for your first name and your last name and then displays your name in reverse order, ie last name followed by the first name.
Question 5:
Write a Java program that inputs temperature in Celsius and prints out the temperature in Fahrenheit. The formula to convert Celsius to Fahrenheit is:
fahrenheit = 1.8 x celsius + 32
Question 6:
Write a Java program that accepts a person’s weight and displays the number of calories the person needs in one day. A person needs 19 calories per pound of body weight, so the formula expressed in Java would be:
calories = bodyWeight * 19