CSC 243 Lab 9, Fall 2012
Lebanese American University · Introduction to Object Oriented Programming · 1 page · Dr. Azzam Mourad
Stuck on a question? A tutor can walk you through it.
More CSC 243 files
Show the text of this lab
LEBANESE AMERICAN UNIVERSITY
School of Arts and Sciences
Department of Computer Science and Mathematics
LAB 9
Dec 11,2012
Problem 1:
Write a program where:
a)
The user input the length of an array N. Then create an array of size N.
b)
Fill the array with N integers that are the grades of a class of students.
c)
Calculate the average of the class using a method called average()
d)
Print all the values of the array, the maximum, the minimum, and the average
Solution: http://www.javaproblems.com/2013/12/manipulating-array-in-java-for-beginners.html
Problem 2:
Write a program that reads 10 values of integers from the user store them in an array of integers.
a.
Then print the reverse of this array.
Example:
1 6 3 4 2 9 8 10 5 7
Reverse: 7 5 10 8 9 2 4 3 6 1
b.
The program writes the array in increasing order. (Using for loops).
Increasing order: 1 2 3 4 5 6 7 8 9 10
Solution: http://www.javaproblems.com/2013/12/reversing-and-sorting-array-in-java.html
Problem 3:
This problem is divided into two parts. First, you should write a program that reads an integer N from the
user and checks if the input is a prime number using a static method boolean isPrime(int N) that returns
true if N is prime and false otherwise. Then, you should extend the program to determine all prime
numbers between 2 and N and store them in an array. You can create an array of size N since the number
of primes between 2 and N is bounded above by N. Finally, all found prime number should be displayed.
Solution: http://www.javaproblems.com/2012/12/prime-numbers-arrays-with-java.html Good luck