Sie sind auf Seite 1von 2

# Java Programming

(Exercises)

1. Write a program that prompts the user to input two digits number. Then the program
should computes and prints the sum of the two numbers, their difference, product, and
quotient. (by using JOptionPane)

2. Write a program that prompts the user to input the height and width of a rectangle and
then prints the rectangle's area and perimeter. (by using Scanner) & (by using
JOptionPane)

3. Write a program that prompts the user to input the length of a square and then prints
the rectangle's area and perimeter. (by using Scanner) & (by using JOptionPane)

4. Write a program that prompts the user to input 5 decimal numbers. The program should
then add the five decimal numbers, convert the sum to integer, and print the result.

5. Write a program that prompts the user to input 5 test scores and then prints the average
test scare.

6. Write a program that prompts the user to input three numbers. The program should
then output the numbers in ascending order. (by using Scanner) & (by using
JOptionPane)

7. Write a program that prompts the user to input three numbers. The program should
then output the numbers in descending order. (by using Scanner) & (by using
JOptionPane)

8. Write a program that prompts the user to input a number. The program should then
output the message saying whether the number is positive, negative or zero. (by using
Scanner) & (by using JOptionPane)
9. Write a program that prompts the user to input three numbers. The program should
then output the sum of all multiplies of 3 between 1 and that number. (by using for
statement)

10. Write a program that prompts the user to input the x-y coordinate of a point in a
Cartesian plane. The program should then output a message indicating whether the
point is the origin, is located on the x (or y) axis, or appears in a particular quadrant. For
example:

## (-2,3) is in the second quadrant

11. Write a program that prompts the user to input 6 numbers. The program should then
output the sum of the even numbers and odd numbers respectively. (by using for
statement) & (by using array)

## 12. Write a complete program that produces the following output:

/\

//\\

///\\\

\\\///

\\//

\/

13. Write a program that displays the following pattern. Use for loops to generate the
pattern. All asterisks (*) should be printed by a single statement of the form
System.out.print("*"). A statement of the form System.ou.println() can be used to move
to next line. A statement of the form System.out.print(" ") can be used to display a
space.

**

***

****

*****