Reference no: EM133743750
Assignment: Computer Science Object Oriented Programming
Question I
Create a java program that do the following:
A. Create an array for a class of 10 students ID (arrStudents1)
B. User inserts students IDs numbers in the array
C. Print out all the elements of the (arrStudents1)
D. Create a new array (arrStudents2) and copy all student IDs from the first array in a reverse order.
E. Using enhanced for loop print all elements from (arrStudents2) on the screen.
Question II
Write a class for the products in retail store with the following requirements.
A. Each product class should have a name, an ID, a description, and a price.
B. The product ID should be incremented automatically in the constructor each time an object is created.
C. Create at least 4 different constructors for the class.
Question III
(1) Identify the issue in following code and (2) correct it.
class Student {
int stuID;
String fName;
double gpa;
Student(int stuID, String fName, double gpa) {
stuID = stuID;
fName = fName;
gpa = gpa;
}
void display() {
System.out.println(stuID + " " + fName + " " + gpa);
}
}
class StudentTest {
public static void main(String args[]) {
Student student1 = new Student(200200100, "Khalid", 3.5);
Student student2 = aStudent(200200200, "Abdulaziz", 3.7);
Student student3 = new Student(200200300, "Mohammed", 2.4);
student1.display();
student2.display();
student3.display();
}
}