SlideShare a Scribd company logo
Tested on Eclipse
Both class should be in same package
/***********UNMember class***********/
import java.util.Scanner;
public class UNMember {
/*data member declaration*/
private String name;
private int NUID;
private String netID;
private String collegeLocation;
Scanner input=new Scanner(System.in);
/*Default constructor*/
public UNMember() {
}
/*Parameterized constructor*/
public UNMember(String name, int nUID, String netID) {
setName(name);
setNUID(nUID);
setNetID(netID);
setCollegeLocation();
}
/*Getter and setter method of data member variable*/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNUID() {
return NUID;
}
public void setNUID(int nUID) {
NUID = nUID;
}
public String getNetID() {
return netID;
}
public void setNetID(String netID) {
this.netID = netID;
}
public String getCollegeLocation() {
return collegeLocation;
}
public void setCollegeLocation() {
String collegeLocation;
/*Prompt for college location*/
System.out.println("Please Enter the college Location");
collegeLocation=input.nextLine();
this.collegeLocation = collegeLocation;
}
@Override
public String toString() {
return "Name:" + name.toUpperCase() + " NUID=" + NUID + " NetID:" +
netID.toUpperCase() + " Campus Location:" + collegeLocation.toUpperCase()
+ " ";
}
}
/************UNStaff class*************/
import java.text.DecimalFormat;
public class UNStaff extends UNMember{
/*Member data variable declaration*/
private String position;
private double wage;
/*Parameterized constructor*/
public UNStaff(String position, double wage,String name,int NUID,String netID) {
super(name,NUID,netID);
setPosition(position);
setWage(wage);
}
/*Getter and Setter method of data member variable*/
public String getPosition() {
return position;
}
public void setPosition(String position) {
if(position.equals("")|| position==null){
this.position="NOT SET";
}else{
this.position = position;
}
}
public double getWage() {
return wage;
}
/*Set wage , if wage less then 9 then we are setting it to -1*/
public void setWage(double wage) {
if(wage<9){
this.wage=-1;
}else{
this.wage = wage;
}
}
/*ToString method*/
@Override
public String toString() {
String result="Position:" + position.toUpperCase() + " ";
if(this.wage==-1){
result+="Wage:NOT SET";
}else{
result+="Wage:$"+new DecimalFormat("##.00").format(this.wage);
}
return super.toString()+result;
}
public static void main(String args[]){
UNStaff staff=new UNStaff("secretary", 50.6, "David", 123, "UN123");
UNStaff staff1=new UNStaff("cleark", 8, "Sam", 129, "UN129");
System.out.println("**************");
System.out.println(staff.toString());
System.out.println("**************");
System.out.println(staff1.toString());
}
}
/***************output*************/
Please Enter the college Location
california
Please Enter the college Location
Los Angeles
**************
Name:DAVID
NUID=123
NetID:UN123
Campus Location:CALIFORNIA
Position:SECRETARY
Wage:$50.60
**************
Name:SAM
NUID=129
NetID:UN129
Campus Location:LOS ANGELES
Position:CLEARK
Wage:NOT SET
Thanks a lot
Solution
Tested on Eclipse
Both class should be in same package
/***********UNMember class***********/
import java.util.Scanner;
public class UNMember {
/*data member declaration*/
private String name;
private int NUID;
private String netID;
private String collegeLocation;
Scanner input=new Scanner(System.in);
/*Default constructor*/
public UNMember() {
}
/*Parameterized constructor*/
public UNMember(String name, int nUID, String netID) {
setName(name);
setNUID(nUID);
setNetID(netID);
setCollegeLocation();
}
/*Getter and setter method of data member variable*/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNUID() {
return NUID;
}
public void setNUID(int nUID) {
NUID = nUID;
}
public String getNetID() {
return netID;
}
public void setNetID(String netID) {
this.netID = netID;
}
public String getCollegeLocation() {
return collegeLocation;
}
public void setCollegeLocation() {
String collegeLocation;
/*Prompt for college location*/
System.out.println("Please Enter the college Location");
collegeLocation=input.nextLine();
this.collegeLocation = collegeLocation;
}
@Override
public String toString() {
return "Name:" + name.toUpperCase() + " NUID=" + NUID + " NetID:" +
netID.toUpperCase() + " Campus Location:" + collegeLocation.toUpperCase()
+ " ";
}
}
/************UNStaff class*************/
import java.text.DecimalFormat;
public class UNStaff extends UNMember{
/*Member data variable declaration*/
private String position;
private double wage;
/*Parameterized constructor*/
public UNStaff(String position, double wage,String name,int NUID,String netID) {
super(name,NUID,netID);
setPosition(position);
setWage(wage);
}
/*Getter and Setter method of data member variable*/
public String getPosition() {
return position;
}
public void setPosition(String position) {
if(position.equals("")|| position==null){
this.position="NOT SET";
}else{
this.position = position;
}
}
public double getWage() {
return wage;
}
/*Set wage , if wage less then 9 then we are setting it to -1*/
public void setWage(double wage) {
if(wage<9){
this.wage=-1;
}else{
this.wage = wage;
}
}
/*ToString method*/
@Override
public String toString() {
String result="Position:" + position.toUpperCase() + " ";
if(this.wage==-1){
result+="Wage:NOT SET";
}else{
result+="Wage:$"+new DecimalFormat("##.00").format(this.wage);
}
return super.toString()+result;
}
public static void main(String args[]){
UNStaff staff=new UNStaff("secretary", 50.6, "David", 123, "UN123");
UNStaff staff1=new UNStaff("cleark", 8, "Sam", 129, "UN129");
System.out.println("**************");
System.out.println(staff.toString());
System.out.println("**************");
System.out.println(staff1.toString());
}
}
/***************output*************/
Please Enter the college Location
california
Please Enter the college Location
Los Angeles
**************
Name:DAVID
NUID=123
NetID:UN123
Campus Location:CALIFORNIA
Position:SECRETARY
Wage:$50.60
**************
Name:SAM
NUID=129
NetID:UN129
Campus Location:LOS ANGELES
Position:CLEARK
Wage:NOT SET
Thanks a lot

More Related Content

PDF
Listing.javaimport java.util.Scanner;public class Listing { Β Β .pdf
PDF
java question Fill the add statement areaProject is to wo.pdf
PDF
operating system linux,ubuntu,Mac Geometri.pdf
PPTX
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
PDF
Can someone help me with this code When I run it, it stops after th.pdf
PDF
(In java language)1. Use recursion in implementing the binarySearc.pdf
PDF
Manual tecnic sergi_subirats
PDF
Polygon .java package chegg2;public class Polygon { Var.pdf
Listing.javaimport java.util.Scanner;public class Listing { Β Β .pdf
java question Fill the add statement areaProject is to wo.pdf
operating system linux,ubuntu,Mac Geometri.pdf
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
Can someone help me with this code When I run it, it stops after th.pdf
(In java language)1. Use recursion in implementing the binarySearc.pdf
Manual tecnic sergi_subirats
Polygon .java package chegg2;public class Polygon { Var.pdf

Similar to Tested on EclipseBoth class should be in same package.pdf (20)

PDF
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
PPTX
Keywords of java
DOCX
OOP Lab Report.docx
PDF
Create a class named Student that has the following member variables.pdf
PDF
public class Person { private String name; private int age;.pdf
PDF
MenuItemvpublic class MenuItem .pdf
PDF
Create a Code that will add an Add, Edi, and Delete button to the GU.pdf
DOC
Email Program By Marcelo
DOC
Email Program By Marcelo
DOC
Email Program By Marcelo
PPT
Core java concepts
PDF
@author public class Person{Β Β  String sname, .pdf
PPT
Core Java
PDF
Code to copy Person.java .pdf
PDF
3. ΠžΠ±ΡŠΠ΅ΠΊΡ‚Ρ‹, классы ΠΈ ΠΏΠ°ΠΊΠ΅Ρ‚Ρ‹ Π² Java
PDF
運用Closure Compiler ζ‰“ι€ ι«˜ε“θ³ͺηš„JavaScript
PPTX
Design patterns
PDF
tested on eclipseDoublyLinkedList class.pdf
PDF
In this lab, we will write an application to store a deck of cards i.pdf
PDF
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
Keywords of java
OOP Lab Report.docx
Create a class named Student that has the following member variables.pdf
public class Person { private String name; private int age;.pdf
MenuItemvpublic class MenuItem .pdf
Create a Code that will add an Add, Edi, and Delete button to the GU.pdf
Email Program By Marcelo
Email Program By Marcelo
Email Program By Marcelo
Core java concepts
@author public class Person{Β Β  String sname, .pdf
Core Java
Code to copy Person.java .pdf
3. ΠžΠ±ΡŠΠ΅ΠΊΡ‚Ρ‹, классы ΠΈ ΠΏΠ°ΠΊΠ΅Ρ‚Ρ‹ Π² Java
運用Closure Compiler ζ‰“ι€ ι«˜ε“θ³ͺηš„JavaScript
Design patterns
tested on eclipseDoublyLinkedList class.pdf
In this lab, we will write an application to store a deck of cards i.pdf
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf

More from anupamagarud8 (20)

PDF
The ligands which show linkage isomers are the onewhich has two dono.pdf
PDF
Strength The main strength of assessment of epidemiology on human h.pdf
PDF
standard deviationB. it is ameasure of variabilitystandard devia.pdf
PDF
Solution A virus achieves host specificity through proteins on th.pdf
PDF
Psychologist Louis L. Thurstones theory of intellegence can be pre.pdf
PDF
Please find the answers and explanations belowPart A The qualita.pdf
PDF
ns1 M.tend to lose electron.lose one electronSolutionn.pdf
PDF
Moles = massmolar mass Moles of ( liqiud indium) = 475114.82=4.1.pdf
PDF
Manifest function Manifest functions is defined as the reactions th.pdf
PDF
In all SolutionIn all .pdf
PDF
import java.util.ArrayList; import java.util.List; import java.u.pdf
PDF
if A U B = implies that A and B both are empty setsboth does.pdf
PDF
hello!Solutionhello!.pdf
PDF
H2A (ACID) MolarityΒ Β Β Β Β Β Β Β  =Β Β Β  0.15 M Normality N1 =Β Β Β  .pdf
PDF
Financial decision making tools includes Financial Statements, Finan.pdf
PDF
D. A reply attack occurs when the attacker can intercept session key.pdf
PDF
Both structural-functionalist perspective on social inequality and K.pdf
PDF
B. SF4Sulfur has an expanded octet in this compound (because it ca.pdf
PDF
B) 0.0968SolutionB) 0.0968.pdf
PDF
Ans. Correct option A. Involves passive water flow down osmotic grad.pdf
The ligands which show linkage isomers are the onewhich has two dono.pdf
Strength The main strength of assessment of epidemiology on human h.pdf
standard deviationB. it is ameasure of variabilitystandard devia.pdf
Solution A virus achieves host specificity through proteins on th.pdf
Psychologist Louis L. Thurstones theory of intellegence can be pre.pdf
Please find the answers and explanations belowPart A The qualita.pdf
ns1 M.tend to lose electron.lose one electronSolutionn.pdf
Moles = massmolar mass Moles of ( liqiud indium) = 475114.82=4.1.pdf
Manifest function Manifest functions is defined as the reactions th.pdf
In all SolutionIn all .pdf
import java.util.ArrayList; import java.util.List; import java.u.pdf
if A U B = implies that A and B both are empty setsboth does.pdf
hello!Solutionhello!.pdf
H2A (ACID) MolarityΒ Β Β Β Β Β Β Β  =Β Β Β  0.15 M Normality N1 =Β Β Β  .pdf
Financial decision making tools includes Financial Statements, Finan.pdf
D. A reply attack occurs when the attacker can intercept session key.pdf
Both structural-functionalist perspective on social inequality and K.pdf
B. SF4Sulfur has an expanded octet in this compound (because it ca.pdf
B) 0.0968SolutionB) 0.0968.pdf
Ans. Correct option A. Involves passive water flow down osmotic grad.pdf

Recently uploaded (20)

PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Β 
PPTX
master seminar digital applications in india
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Classroom Observation Tools for Teachers
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
Institutional Correction lecture only . . .
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Cell Structure & Organelles in detailed.
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
01-Introduction-to-Information-Management.pdf
PDF
RMMM.pdf make it easy to upload and study
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Β 
master seminar digital applications in india
Abdominal Access Techniques with Prof. Dr. R K Mishra
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Anesthesia in Laparoscopic Surgery in India
Classroom Observation Tools for Teachers
A systematic review of self-coping strategies used by university students to ...
Module 4: Burden of Disease Tutorial Slides S2 2025
Final Presentation General Medicine 03-08-2024.pptx
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Institutional Correction lecture only . . .
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Cell Structure & Organelles in detailed.
FourierSeries-QuestionsWithAnswers(Part-A).pdf
VCE English Exam - Section C Student Revision Booklet
01-Introduction-to-Information-Management.pdf
RMMM.pdf make it easy to upload and study

Tested on EclipseBoth class should be in same package.pdf

  • 1. Tested on Eclipse Both class should be in same package /***********UNMember class***********/ import java.util.Scanner; public class UNMember { /*data member declaration*/ private String name; private int NUID; private String netID; private String collegeLocation; Scanner input=new Scanner(System.in); /*Default constructor*/ public UNMember() { } /*Parameterized constructor*/ public UNMember(String name, int nUID, String netID) { setName(name); setNUID(nUID); setNetID(netID); setCollegeLocation(); } /*Getter and setter method of data member variable*/ public String getName() { return name; } public void setName(String name) { this.name = name; } public int getNUID() { return NUID; } public void setNUID(int nUID) { NUID = nUID; }
  • 2. public String getNetID() { return netID; } public void setNetID(String netID) { this.netID = netID; } public String getCollegeLocation() { return collegeLocation; } public void setCollegeLocation() { String collegeLocation; /*Prompt for college location*/ System.out.println("Please Enter the college Location"); collegeLocation=input.nextLine(); this.collegeLocation = collegeLocation; } @Override public String toString() { return "Name:" + name.toUpperCase() + " NUID=" + NUID + " NetID:" + netID.toUpperCase() + " Campus Location:" + collegeLocation.toUpperCase() + " "; } } /************UNStaff class*************/ import java.text.DecimalFormat; public class UNStaff extends UNMember{ /*Member data variable declaration*/ private String position; private double wage; /*Parameterized constructor*/ public UNStaff(String position, double wage,String name,int NUID,String netID) { super(name,NUID,netID); setPosition(position); setWage(wage);
  • 3. } /*Getter and Setter method of data member variable*/ public String getPosition() { return position; } public void setPosition(String position) { if(position.equals("")|| position==null){ this.position="NOT SET"; }else{ this.position = position; } } public double getWage() { return wage; } /*Set wage , if wage less then 9 then we are setting it to -1*/ public void setWage(double wage) { if(wage<9){ this.wage=-1; }else{ this.wage = wage; } } /*ToString method*/ @Override public String toString() { String result="Position:" + position.toUpperCase() + " "; if(this.wage==-1){ result+="Wage:NOT SET"; }else{ result+="Wage:$"+new DecimalFormat("##.00").format(this.wage); } return super.toString()+result; } public static void main(String args[]){
  • 4. UNStaff staff=new UNStaff("secretary", 50.6, "David", 123, "UN123"); UNStaff staff1=new UNStaff("cleark", 8, "Sam", 129, "UN129"); System.out.println("**************"); System.out.println(staff.toString()); System.out.println("**************"); System.out.println(staff1.toString()); } } /***************output*************/ Please Enter the college Location california Please Enter the college Location Los Angeles ************** Name:DAVID NUID=123 NetID:UN123 Campus Location:CALIFORNIA Position:SECRETARY Wage:$50.60 ************** Name:SAM NUID=129 NetID:UN129 Campus Location:LOS ANGELES Position:CLEARK Wage:NOT SET Thanks a lot Solution Tested on Eclipse Both class should be in same package /***********UNMember class***********/ import java.util.Scanner;
  • 5. public class UNMember { /*data member declaration*/ private String name; private int NUID; private String netID; private String collegeLocation; Scanner input=new Scanner(System.in); /*Default constructor*/ public UNMember() { } /*Parameterized constructor*/ public UNMember(String name, int nUID, String netID) { setName(name); setNUID(nUID); setNetID(netID); setCollegeLocation(); } /*Getter and setter method of data member variable*/ public String getName() { return name; } public void setName(String name) { this.name = name; } public int getNUID() { return NUID; } public void setNUID(int nUID) { NUID = nUID; } public String getNetID() { return netID; } public void setNetID(String netID) { this.netID = netID;
  • 6. } public String getCollegeLocation() { return collegeLocation; } public void setCollegeLocation() { String collegeLocation; /*Prompt for college location*/ System.out.println("Please Enter the college Location"); collegeLocation=input.nextLine(); this.collegeLocation = collegeLocation; } @Override public String toString() { return "Name:" + name.toUpperCase() + " NUID=" + NUID + " NetID:" + netID.toUpperCase() + " Campus Location:" + collegeLocation.toUpperCase() + " "; } } /************UNStaff class*************/ import java.text.DecimalFormat; public class UNStaff extends UNMember{ /*Member data variable declaration*/ private String position; private double wage; /*Parameterized constructor*/ public UNStaff(String position, double wage,String name,int NUID,String netID) { super(name,NUID,netID); setPosition(position); setWage(wage); } /*Getter and Setter method of data member variable*/ public String getPosition() { return position; }
  • 7. public void setPosition(String position) { if(position.equals("")|| position==null){ this.position="NOT SET"; }else{ this.position = position; } } public double getWage() { return wage; } /*Set wage , if wage less then 9 then we are setting it to -1*/ public void setWage(double wage) { if(wage<9){ this.wage=-1; }else{ this.wage = wage; } } /*ToString method*/ @Override public String toString() { String result="Position:" + position.toUpperCase() + " "; if(this.wage==-1){ result+="Wage:NOT SET"; }else{ result+="Wage:$"+new DecimalFormat("##.00").format(this.wage); } return super.toString()+result; } public static void main(String args[]){ UNStaff staff=new UNStaff("secretary", 50.6, "David", 123, "UN123"); UNStaff staff1=new UNStaff("cleark", 8, "Sam", 129, "UN129"); System.out.println("**************"); System.out.println(staff.toString()); System.out.println("**************");
  • 8. System.out.println(staff1.toString()); } } /***************output*************/ Please Enter the college Location california Please Enter the college Location Los Angeles ************** Name:DAVID NUID=123 NetID:UN123 Campus Location:CALIFORNIA Position:SECRETARY Wage:$50.60 ************** Name:SAM NUID=129 NetID:UN129 Campus Location:LOS ANGELES Position:CLEARK Wage:NOT SET Thanks a lot