Sayeq Learning Center Java #2
1. Find the largest and smallest byte, short, int, long, float, and
double. Which of these data types requires the least amount of
memory?
2. If today is Tuesday, what will be the day in 100 days?
3. Which of the following are correct literals for floating-point
numbers?
12.3, 12.3e+2, 23.4e-2, –334.4, 20.5, 39F, 40D
4. Which of the following are the same as 52.534?
5.2534e+1, 0.52534e+2, 525.34e-1, 5.2534e+0
5. Which of the following are correct literals?
5_2534e+1, _2534, 5_2, 5_
6. How do you obtain the current second, minute, and hour?
7. Show the output of the following code:
int a = 6;
int b = a++;
[Link](a);
[Link](b);
a = 6;
b = ++a;
[Link](a);
[Link](b);
8. Can different types of numeric values be used together in a
computation?
0798481417:شماره تماس
@herat_sayeq
ابتدای سرک پوهنتون هرات:آدرس
Sayeq Learning Center Java #2
9. If you change (int)(tax * 100) / 100.0 to (int)(tax * 100) / 100
in line 11 in Listing 2.8, what will be the output for the input
purchase amount of 197.556?
10. (Compute the volume of a triangle) Write a program that reads in
the length of sides of an equilateral triangle and computes the area
and volume using the following formulas:
√3
area = 4 (length of sides)2
volume = area * length
11. (Convert meters into feet) Write a program that reads a number in
meters, converts it to feet, and displays the result. One meter is
3.2786 feet
12. (Multiply the digits in an integer) Write a program that reads an
integer between 0 and 1000 and multiplies all the digits in the
integer. For example, if an integer is 932, the multiplication of all
its digits is 54.
13. (Find the number of years) Write a program that prompts the user
to enter the minutes (e.g., 1 billion), and displays the number of
years and remaining days for the minutes. For simplicity, assume
that a year has 365 days.
14. (Physics: finding runway length) Given an airplane’s acceleration
a and take-off speed v, you can compute the minimum runway
0798481417:شماره تماس
@herat_sayeq
ابتدای سرک پوهنتون هرات:آدرس
Sayeq Learning Center Java #2
length needed for an airplane to take off using the following
2
formula: length = 2va
15. Write a program that prompts the user to enter v in meters/second
(m/s) and the acceleration a in meters/second squared (m/s2), then,
displays the minimum runway length
16. (Health application: computing BMI) Body Mass Index (BMI) is a
measure of health on weight. It can be calculated by taking your
weight in kilograms and dividing, by the square of your height in
meters. Write a program that prompts the user to enter a weight in
pounds and height in inches and displays the BMI. Note one pound
is 0.45359237 kilograms and one inch is 0.0254 meters.
0798481417:شماره تماس
@herat_sayeq
ابتدای سرک پوهنتون هرات:آدرس