Can anyone help me with the Java project? Please please provide the solution und
ID: 3568936 • Letter: C
Question
Can anyone help me with the Java project? Please please provide the solution under the question. I will appreciate a lot!!!Design and implement a set of classes that function as a database for the people at the college. People can be broadly broken down into staff, faculty, and students. Each of these have attributes that are unique...but they all have things would be stored in common (name, phone, addr, SS#). Similarly, they have some methods in common and some unique to the position. You should have a a couple of both. You don't have to make this interactive unless you want to do so. But you should create at least two entries for each and show the methods working.
Thanks! Can anyone help me with the Java project? Please please provide the solution under the question. I will appreciate a lot!!!
Design and implement a set of classes that function as a database for the people at the college. People can be broadly broken down into staff, faculty, and students. Each of these have attributes that are unique...but they all have things would be stored in common (name, phone, addr, SS#). Similarly, they have some methods in common and some unique to the position. You should have a a couple of both. You don't have to make this interactive unless you want to do so. But you should create at least two entries for each and show the methods working.
Thanks!
Design and implement a set of classes that function as a database for the people at the college. People can be broadly broken down into staff, faculty, and students. Each of these have attributes that are unique...but they all have things would be stored in common (name, phone, addr, SS#). Similarly, they have some methods in common and some unique to the position. You should have a a couple of both. You don't have to make this interactive unless you want to do so. But you should create at least two entries for each and show the methods working.
Thanks!
Explanation / Answer
Program Code:
//Staff.java
public class Staff
{
String name;
String stream;
double salary;
String phonenum;
String address;
int SSN;
public Staff()
{
name=null;
phonenum=null;
address=null;
SSN=0;
}
public void setName(String nam)
{
name=nam;
}
public void setPhoneNum(String phone)
{
phonenum=phone;
}
public void setAddress(String add)
{
address=add;
}
public void setStream(String strm)
{
stream=strm;
}
public void setSSN(int ssnum)
{
SSN=ssnum;
}
public String getName()
{
return name;
}
public String getPhoneNum()
{
return phonenum;
}
public String getAddress()
{
return address;
}
public void setSalary(double sal)
{
salary=sal;
}
public double getSalary()
{
return salary;
}
public int getSSN()
{
return SSN;
}
public String getStream()
{
return stream;
}
public String toString()
{
String s="";
s+=getSSN()+" "+getName()+" "+getPhoneNum()+" "+getAddress()+
" "+getStream()+" "+getSalary()+" ";
return s;
}
}
//Faculty.java
public class Faculty
{
String name;
String department;
double salary;
String phonenum;
String address;
int SSN;
public Faculty()
{
name=null;
phonenum=null;
address=null;
SSN=0;
}
public void setName(String nam)
{
name=nam;
}
public void setPhoneNum(String phone)
{
phonenum=phone;
}
public void setDepartment(String dep)
{
department=dep;
}
public void setSalary(double sal)
{
salary=sal;
}
public void setAddress(String add)
{
address=add;
}
public void setSSN(int ssnum)
{
SSN=ssnum;
}
public String getName()
{
return name;
}
public String getPhoneNum()
{
return phonenum;
}
public String getAddress()
{
return address;
}
public int getSSN()
{
return SSN;
}
public String getDepartment()
{
return department;
}
public double getSalary()
{
return salary;
}
public String toString()
{
String s="";
s+=getSSN()+" "+getName()+" "+getPhoneNum()+" "+getAddress()+
" "+getDepartment()+" "+getSalary()+"$ ";
return s;
}
}
//Students.java
import java.text.*;
public class Students
{
String name;
String phonenum;
String address;
int sub1, sub2, sub3;
double average;
char grade;
int SSN;
DecimalFormat df = new DecimalFormat("##.00");
Students()
{
name=null;
phonenum=null;
address=null;
SSN=0;
}
public void setName(String nam)
{
name=nam;
}
public void setPhoneNum(String phone)
{
phonenum=phone;
}
public void setAddress(String add)
{
address=add;
}
public void setSSN(int ssnum)
{
if(String.valueOf(ssnum).length()==9)
SSN=ssnum;
else
System.out.println("Please enter the SSN number of 9 digits.");
}
public void setMarks1(int m)
{
sub1=m;
}
public void setMarks2(int m)
{
sub2=m;
}
public void setMarks3(int m)
{
sub3=m;
}
public String getName()
{
return name;
}
public String getPhoneNum()
{
return phonenum;
}
public String getAddress()
{
return address;
}
public int getSSN()
{
return SSN;
}
public int getTotal()
{
return sub1+sub2+sub3;
}
public double getAverage()
{
int total=getTotal();
average=(total/3.0);
return average;
}
public char getGrade(double avg)
{
if(avg>=90 && avg <=99)
{
return 'A';
}
else if(avg>=80 && avg <=89)
{
return 'B';
}
else if(avg>=70 && avg <=79)
{
return 'C';
}
else if(avg>=60 && avg <=69)
{
return 'D';
}
else if(avg>=0 && avg <=59)
{
return 'F';
}
else
return '0';
}
public int getSub1Marks()
{
return sub1;
}
public int getSub2Marks()
{
return sub2;
}
public int getSub3Marks()
{
return sub3;
}
public String toString()
{
String s="";
s+=getSSN()+" "+getName()+" "+getPhoneNum()+" "+getAddress()+
" "+ getSub1Marks()+" "+getSub2Marks()+" "+getSub3Marks()+" "+
getTotal()+" "+df.format(getAverage())+" "+getGrade(average)+" ";
return s;
}
}
//implementationClass.java
import java.util.*;
public class ImplementationClass
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
ArrayList<Students>stud=new ArrayList<Students>();
ArrayList<Faculty>faculty=new ArrayList<Faculty>();
ArrayList<Staff>staff=new ArrayList<Staff>();
Students s=new Students();
System.out.println("Students Data");
s.setSSN(332244551);
s.setName("Alexander");
s.setPhoneNum("123-56789");
s.setAddress("21Street, NewYork");
s.setMarks1(65);
s.setMarks2(75);
s.setMarks3(80);
stud.add(s);
Students s1=new Students();
s1.setSSN(302040501);
s1.setName("Michael");
s1.setPhoneNum("987-12345");
s1.setAddress("36Street, NewJerssy");
s1.setMarks1(95);
s1.setMarks2(75);
s1.setMarks3(90);
stud.add(s1);
System.out.println("The data present in the Students database is: ");
System.out.printf("SSN Name PhoneNum Address m1 m2 m3 total Average Grade");
System.out.println();
for(int i=0;i<stud.size();i++)
{
System.out.println(stud.get(i).toString());
}
System.out.println("*********************************** ");
System.out.println("Faculty Data");
Faculty f=new Faculty();
f.setSSN(987654321);
f.setName("Laurence");
f.setPhoneNum("234-65874");
f.setAddress("21Jonson street, NY");
f.setDepartment("Electrical");
f.setSalary(2000);
faculty.add(f);
Faculty f1=new Faculty();
f1.setSSN(302105467);
f1.setName("Gregory");
f1.setPhoneNum("132-65004");
f1.setAddress("89 street, Mexico");
f1.setDepartment("Computer Science");
f1.setSalary(2500);
faculty.add(f1);
System.out.println("The data present in the Faculty database is: ");
System.out.printf("SSN Name PhoneNum Address Department salary");
System.out.println();
for(int i=0;i<faculty.size();i++)
{
System.out.println(faculty.get(i).toString());
}
System.out.println("*********************************** ");
Staff sf=new Staff();
System.out.println("Staff Data");
sf.setSSN(200300100);
sf.setName("Leo Alexandar");
sf.setPhoneNum("456-12378");
sf.setAddress("29St.Michael Street, NY");
sf.setStream("OfficeStaff");
sf.setSalary(1500);
staff.add(sf);
Staff sf1=new Staff();
sf1.setSSN(102304056);
sf1.setName("Gregory Lenin");
sf1.setPhoneNum("102-60000");
sf1.setAddress("9 street, Mexico");
sf1.setStream("Librarian");
sf1.setSalary(500);
staff.add(sf1);
System.out.println("The data present in the Staff database is: ");
System.out.printf("SSN Name PhoneNum Address Stream salary");
System.out.println();
for(int i=0;i<staff.size();i++)
{
System.out.println(staff.get(i).toString());
}
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------------
Sample Output:
Students Data
The data present in the Students database is:
SSN Name PhoneNum Address m1 m2 m3 total Average Grade
332244551 Alexander 123-56789 21Street, NewYork 65 75 80 220 73.33 C
302040501 Michael 987-12345 36Street, NewJerssy 95 75 90 260 86.67 B
***********************************
Faculty Data
The data present in the Faculty database is:
SSN Name PhoneNum Address Department salary
987654321 Laurence 234-65874 21Jonson street, NY Electrical 2000.0$
302105467 Gregory 132-65004 89 street, Mexico Computer Science 2500.0$
***********************************
Staff Data
The data present in the Staff database is:
SSN Name PhoneNum Address Stream salary
200300100 Leo Alexandar 456-12378 29St.Michael Street, NY OfficeStaff 1500.0
102304056 Gregory Lenin 102-60000 9 street, Mexico Librarian 500.0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.