ITEC 1620 Assignment 2: Java Program for Student Details
VerifiedAdded on  2022/08/25
|9
|834
|20
Homework Assignment
AI Summary
This Java programming assignment solution comprises two Java files: a `studentclass` and a `Main` class. The `studentclass` defines a student object with instance variables such as name, ID, location, marks, and subject, along with methods for searching and updating student information. The `Main` class instantiates multiple student objects, stores them in an `ArrayList`, and demonstrates the usage of the methods defined in the `studentclass`, including displaying student details, searching for a student, and updating a student's marks. The solution effectively utilizes inheritance and the `ArrayList` data structure to manage and manipulate student data, addressing the assignment requirements of creating a class with instance variables and methods, and a main program to test those methods.

Running head: JAVA PROGRAMMING ASSIGNMENT
Java Programming assignment
Name of the Student
Name of the University
Authors note
Java Programming assignment
Name of the Student
Name of the University
Authors note
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

1JAVA PROGRAMMING ASSIGNMENT
In order to complete this assignment, the concept of inheritance and array lists are used.
For storing the array of objects, the array list is utilized. The ArrayList belongs to the collection
framework available in java which comes under the java.util package. Through this package we
can declare and use dynamic arrays in programs. Even though these collections are
comparatively slower than standard arrays. Here, it can be stated that the array lists are very
helpful in the applications where too many manipulations on the declared array is required.
ArrayList mainly inherits AbstractList class of java. Whenever used in the program it
implements List interface and executed in the program in order to store and manipulate the data
in the array. Even though the ArrayLists can be initialized with a specific size, but the size and
required memory can be increased or decreased whenever collection of data or objects are
increased or decreased depending upon the addition and removal of data from collection. The
ArrayList are also helpful in reducing required time for computations as it allows random access
to the list of objects. Here, it is important to mention that ArrayList objects are not to be used for
the storage and manipulation of the primitive data types such as int, double, char, string and so
on. In order to do so it is important to use a wrapper class. While developing the student details
program in Java, it is found that the ArrayList are capable of storing duplicate elements,
preserves insertion order of the objects/elements and non-synchronized. In case of the multi-
threaded environment, it is possible that too many threads will try to access or modify an
specific ArrayList simultaneously in that scenario final result becomes non-deterministic due to
the non-synchronized nature.
Student class
package pkg1225347;
In order to complete this assignment, the concept of inheritance and array lists are used.
For storing the array of objects, the array list is utilized. The ArrayList belongs to the collection
framework available in java which comes under the java.util package. Through this package we
can declare and use dynamic arrays in programs. Even though these collections are
comparatively slower than standard arrays. Here, it can be stated that the array lists are very
helpful in the applications where too many manipulations on the declared array is required.
ArrayList mainly inherits AbstractList class of java. Whenever used in the program it
implements List interface and executed in the program in order to store and manipulate the data
in the array. Even though the ArrayLists can be initialized with a specific size, but the size and
required memory can be increased or decreased whenever collection of data or objects are
increased or decreased depending upon the addition and removal of data from collection. The
ArrayList are also helpful in reducing required time for computations as it allows random access
to the list of objects. Here, it is important to mention that ArrayList objects are not to be used for
the storage and manipulation of the primitive data types such as int, double, char, string and so
on. In order to do so it is important to use a wrapper class. While developing the student details
program in Java, it is found that the ArrayList are capable of storing duplicate elements,
preserves insertion order of the objects/elements and non-synchronized. In case of the multi-
threaded environment, it is possible that too many threads will try to access or modify an
specific ArrayList simultaneously in that scenario final result becomes non-deterministic due to
the non-synchronized nature.
Student class
package pkg1225347;

2JAVA PROGRAMMING ASSIGNMENT
import java.util.Scanner;
/**
*
* @author user
*/
public class studentclass {
String Name;
int id;
String loc;
double marks;
String subject;
public studentclass(String Name, int id, String loc, double marks, String subject)
{
this.Name=Name;
this.id=id;
import java.util.Scanner;
/**
*
* @author user
*/
public class studentclass {
String Name;
int id;
String loc;
double marks;
String subject;
public studentclass(String Name, int id, String loc, double marks, String subject)
{
this.Name=Name;
this.id=id;
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

3JAVA PROGRAMMING ASSIGNMENT
this.loc=loc;
this.marks=marks;
this.subject=subject;
}
public studentclass() {
}
public String toString(){
return "("+Name+","+id+","+loc+","+marks+","+subject+")";
}
public void search(studentclass stu, String name)
{
this.loc=loc;
this.marks=marks;
this.subject=subject;
}
public studentclass() {
}
public String toString(){
return "("+Name+","+id+","+loc+","+marks+","+subject+")";
}
public void search(studentclass stu, String name)
{
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

4JAVA PROGRAMMING ASSIGNMENT
if(stu.Name==name){
System.out.println("The Student is in list");
}
else
{
System.out.println("The Student Record not found");
}
}
public void update(studentclass stu, String name)
{
if(stu.Name==name){
Scanner in = new Scanner(System.in);
System.out.println("Enter new value for marks");
String input = in.nextLine();
if(stu.Name==name){
System.out.println("The Student is in list");
}
else
{
System.out.println("The Student Record not found");
}
}
public void update(studentclass stu, String name)
{
if(stu.Name==name){
Scanner in = new Scanner(System.in);
System.out.println("Enter new value for marks");
String input = in.nextLine();

5JAVA PROGRAMMING ASSIGNMENT
stu.marks=Integer.parseInt( input );
}
else
{
System.out.println("No record found");
}
}
}
Main class
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pkg1225347;
stu.marks=Integer.parseInt( input );
}
else
{
System.out.println("No record found");
}
}
}
Main class
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pkg1225347;
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

6JAVA PROGRAMMING ASSIGNMENT
import java.util.ArrayList;
/**
*
* @author user
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
studentclass sm=new studentclass();
ArrayList arlist=new ArrayList();
studentclass s0=new studentclass("John",101,"Michigan",25.5,"History");
studentclass s01=new
studentclass("Jacob",102,"Bangalore",40,"Mathematics");
import java.util.ArrayList;
/**
*
* @author user
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
studentclass sm=new studentclass();
ArrayList arlist=new ArrayList();
studentclass s0=new studentclass("John",101,"Michigan",25.5,"History");
studentclass s01=new
studentclass("Jacob",102,"Bangalore",40,"Mathematics");
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

7JAVA PROGRAMMING ASSIGNMENT
studentclass s02=new studentclass("Kate",103,"Detroit",45.8,"Biology");
studentclass s03=new
studentclass("Rolland",104,"California",15.2,"Physics");
studentclass s04=new
studentclass("Timothy",105,"Philladelphia",38.8,"calculas");
arlist.add(s0);
arlist.add(s01);
arlist.add(s02);
arlist.add(s03);
arlist.add(s04);
arlist.forEach((stut) -> {
System.out.println(stut.toString());
});
sm.search(s01, "John");
sm.update(s04, "Kate");
studentclass s02=new studentclass("Kate",103,"Detroit",45.8,"Biology");
studentclass s03=new
studentclass("Rolland",104,"California",15.2,"Physics");
studentclass s04=new
studentclass("Timothy",105,"Philladelphia",38.8,"calculas");
arlist.add(s0);
arlist.add(s01);
arlist.add(s02);
arlist.add(s03);
arlist.add(s04);
arlist.forEach((stut) -> {
System.out.println(stut.toString());
});
sm.search(s01, "John");
sm.update(s04, "Kate");

8JAVA PROGRAMMING ASSIGNMENT
arlist.forEach((stut) -> {
System.out.println(stut.toString());
});
}
}
arlist.forEach((stut) -> {
System.out.println(stut.toString());
});
}
}
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide
1 out of 9
Related Documents

Your All-in-One AI-Powered Toolkit for Academic Success.
 +13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.