Java Worksheet One

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Java Worksheet I

1. Create a one dimensional array and its ten elements should be a random numbers between
one up to 100. Additionally, print only prime numbers(Hint: use random and round
methods of Math class)
Sample output:

2. Create a two dimensional array based on the number of rows and columns accepted from
user and accept each element from user. Then, do the following operations:
a. Print sum of the first row elements.
b. Print the second column elements.
c. If the user wishes to perform the above operations again, the loop should repeat
otherwise the program should terminate.
Sample output:

3. Write a program that can ccept total mark of five students and print the equivalent grade.
Sample output:
4. Write a program that can accept as many number as the user wishes to enter. And print
only even numbers, odd numbers, sum of numbers, maximum and minimum numbers as
shown on the sample output. The program should continue as long as the user doesn’t
quit. Sample outputs:

To print even numbers, number of even numbers and their sum:

To print odd numbers, number of odd numbers and their sum:

To print maximum and minimum numbers:

To quit

You might also like