Person.java:97: class, interface, or enum expected HeadofHousehold file in java
ID: 3618572 • Letter: P
Question
Person.java:97: class, interface, or enum expected
HeadofHousehold file in java
Person.java:106: invalid, method declaration; return typerequired
Public headofHousehold(boolean status)
Person.java:161:class, interface, or enum expected
Dependent class file
Person.java:161: ‘{‘ expected
Dependent class file
Person.java:178: reached end of file while parsing
5 errors
===================================================================
Explanation / Answer
I have modified the classes. I removed static from all thefunctions, if you need it just add Public static to all thevariables and Functions. Make sure, there should not be any privetstatic accessor methods. Main Method also missing. Let me know, still if you face any issues in compiling this. //Person.Java class Person { // declare needed variables int gender; // options: 0 = unreported, 1= male, 2 = female int age = 0; int marriedstatus = 0; //0=not-reported,1=single,2=married,3=divorced double familyincome = 0.0; String maxeducation; // options: 0 = no HSdiploma, 1 = high school, 2 = college int personsinhousehold = 0; /* sets value for gender */ public void recordgender(int x) { this.gender = x; } // end recordgender() /* sets value for age */ public void recordage(int x) { this.age = x; } // end recordage() /* sets value for married status */ public void recordmarriedstatus(int x) { this.marriedstatus = x; }// end recordmarriedstatus() public void recordfamilyincome(doublex) { this.familyincome = x; }// end recordfamilyincome() /* maxeducation String */ public void recordmaxeducation(int x) { switch(x) { case 0: this.maxeducation = "no High School diploma"; break; case 1: this.maxeducation = "High School graduate"; break; case 2: this.maxeducation = "college"; break; } }// end recordmaxeducation() /* sets value for personsinhousehold */ public void recordpersonsinhousehold(int x) { if(x < 1) x = 1; //the person answering is in the household this.personsinhousehold =x; } // end recordpersonsinhousehold() /* reports details related to a person */ public void personreport() { System.out.printf(" *********************** "); System.out.println("This person's dataincludes:"); System.out.print("Gender: "); if(this.gender == 1) System.out.println("male"); else if(this.gender == 2) System.out.println("female"); else System.out.println("unreported"); System.out.println("Age: " +this.age); System.out.printf("Family income:$%10.2f ", this.familyincome); System.out.print("Highest level ofeducation: "); System.out.println(maxeducation); System.out.println("Total number of familymembers indicates "); if((this.personsinhousehold > 2)&&(this.personsinhousehold < 5)) System.out.println("average sized household"); else if((this.personsinhousehold ==1)||(this.personsinhousehold == 2)) System.out.println("smaller thanaverage sized household"); else System.out.println("larger thanaverage sized household"); } // end personreport() } // end class Person //HeadofHouseHold.java class HeadOfHoushold extends Person { static boolean ishead; int householdsize; int married; double totalincome; public HeadOfHoushold(boolean status) { ishead=status; } public int gethouseholdsize() { returnhouseholdsize; } public int getgender() { return gender; } public int getage() { returnage; } public int getmarried() { returnmarried; } public double getincome() { returntotalincome; } public String getmaxeducation() { returnmaxeducation; } } //Dependents.java class Dependent extends Person { boolean isdependent; public Dependent(boolean status) { isdependent=status; } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.