2/08/2015

BCS2233 OOP: LAB WEEK 3


Programming Exercises


2.1 (Converting Fahrenheit to Celsius) Write a program that reads a Fahrenheit degree in double from an input dialog box, then converts it to Celsius and displays the result in a message dialog box. The formula for the conversion is as follows:
celsius = (5/9) * (fahrenheit - 32)

Hint


  In Java, 5 / 9 is 0, so you need to write 5.0 / 9 in the program to obtain the correct result.



2.2 (Computing the volume of a cylinder) Write a program that reads in the radius and length of a cylinder and computes its volume using the following formulas:

area = radius * radius * p
volume = area * length


2.3 (Converting feet into meters) Write a program that reads a number in feet, converts it to meters, and displays the result. One foot is 0.305 meters.

2.4 (Converting pounds into kilograms) Write a program that converts pounds into kilograms. The program prompts the user to enter a number in pounds, converts it to kilograms, and displays the result. One pound is 0.454 kilograms.

2.5* (Calculating tips) Write a program that reads the subtotal and the gratuity rate, and computes the gratuity and total. For example, if the user enters 10 for subtotal and 15% for gratuity rate, the program displays $1.5 as gratuity and $11.5 as total.

2.6** (Summing the digits in an integer) Write a program that reads an integer between 0 and 1000 and adds all the digits in the integer. For example, if an integer is 932, the sum of all its digits is 14.
Hint


  Use the % operator to extract digits, and use the / operator to remove the extracted digit. For instance, 932 % 10 = 2 and 932 / 10 = 93

No comments:

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...