Sie sind auf Seite 1von 2

1. Write a Java program to print ...

'Hello' on screen and then print 8 x 10 = 80


your name on a separate line.
8. Write a Java program to display the
Expected Output: following pattern
Hello
Sample Pattern:
Juan Dela Cruz
J a v v a
J a a v v a a
2. Write a Java program to print the J J aaaaa V V aaaaa
sum of two numbers JJ a a V a a

Test Data: 9. Write a Java program to compute the


74 + 36 specified expressions and print the
Expected Output: output
110
Test Data:
3. Write a Java program to divide two ((25.5 * 3.5 - 3.5 * 3.5) / (40.5 -
numbers and print on the screen 4.5))
Expected Output
Test Data: 2.138888888888889
50/3
Expected Output: 10. Write a Java program to
16 compute a specified formula

4. Write a Java program to print the Specified Formula:


result of the following operations 4.0 * (1 - (1.0/3) + (1.0/5) -
(1.0/7) + (1.0/9) - (1.0/11))
Test Data: Expected Output
a. -5 + 8 * 6 2.9760461760461765
b. (55+9) % 9
c. 20 + -3*5 / 8 11. Write a Java program to print
d. 5 + 15 / 3 * 2 - 8 % 3 the area and perimeter of a circle
Expected Output :
43 Test Data:
1 Radius = 7.5
19 Expected Output
13 Perimeter is = 47.12388980384689
Area is = 176.71458676442586
5. Write a Java program that takes two
numbers as input and display the 12. Write a Java program that
product of two numbers. takes three numbers as input to
Test Data: calculate and print the average of
Input first number: 25 the numbers
Input second number: 5
Expected Output : 13. Write a Java program to print
25 x 5 = 125 the area and perimeter of a
rectangle.
6. Write a Java program to print the Test Data:
sum (addition), multiply, subtract, Width = 5.5 Height = 8.5
divide and remainder of two numbers
Test Data: Expected Output
Input first number: 125 Area is 5.6 * 8.5 = 47.60
Input second number: 24 Perimeter is 2 * (5.6 + 8.5) = 47.60
Expected Output :
125 + 24 = 149 14. Write a Java program to print
125 - 24 = 101 a face.
125 x 24 = 3000
125 / 24 = 5 Expected Output
125 mod 24 = 5
+"""""+
7. Write a Java program that takes a [| o o |]
number as input and prints its | ^ |
multiplication table up to 10. | '-' |
+-----+
Test Data:
Input a number: 8 15. Write a Java program to print
Expected Output : the flag of the Philippines
8 x 1 = 8
8 x 2 = 16
8 x 3 = 24
Data Types Exercises
5. Write a Java program that
accepts two integers from
1. Write a Java program to the user and then prints
convert temperature from the sum, the difference,
Fahrenheit to Celsius the product, the average,
degree the distance (the
difference between
Test Data integer), the maximum (the
Input a degree in larger of the two
Fahrenheit: 212 integers), the minimum
Expected Output: (smaller of the
212.0 degree Fahrenheit is two integers).
equal to 100.0 in Celsius
Test Data
2. Write a Java program that Input 1st integer: 25
reads a number in inches, Input 2nd integer: 5
converts it to meters Expected Output :
Sum of two integers: 30
Note: One inch is 0.0254 Difference of two integers:
meter. 20
Test Data Product of two integers:
Input a value for inch: 125
1000 Average of two integers:
Expected Output: 15.00
1000.0 inch is 25.4 meters Distance of two integers:
20
3. Write a Java program that Max integer: 25
reads an integer between 0 Min integer: 5
and 1000 and adds all the
digits in the integer

Test Data
Input an integer between 0
and 1000: 565
Expected Output:
The sum of all digits in
565 is 16

4. Write a Java program to


compute body mass index
(BMI)

Test Data
Input weight in pounds: 452
Input height in inches: 72
Expected Output:
Body Mass Index is
61.30159143458721

Das könnte Ihnen auch gefallen