SlideShare a Scribd company logo
Please help me find my error/s. I am lost as I know what the problem is but not sure how to fix it.
Problem: Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method getNumberofdays() is undefined for the type Year
The method getNumberofdays() is undefined for the type LeapYear
at UseYear.main(UseYear.java:11)
UseYear.java
public class UseYear
{
public static void main(String args[])
{
//Initializing class
Year year = new Year();
//Calling method to display days
year.getNumberofdays();
//Initializing class
LeapYear leapyear = new LeapYear();
//Calling to display days
leapyear.getNumberofdays();
}
}
LeapYear.java
public class LeapYear extends Year
{
//Constructor for LeapYear class
public LeapYear()
{
setNumberofdays(366);
}
}
Year.java
public class Year
{
//Variable
int numberofdays;
public void getNumberofdays
{
System.out.println(numberofdays);
}
//Method to set the value
public void setNumberofdays(int numberofdays)
{
this.numberofdays = numberofdays;
}
//Constructor for Year class
public Year()
{
setNumberofdays(365);
}
}
UseYear2.java
public class UseYear2
{
public static void main(String args[])
{
int day = 2, month = 3;
//Initializing class
Year2 year = new Year2();
//Initializing class
LeapYear2 leapyear = new LeapYear2();
//Display days elapsed
System.out.println("Days elapsed in a Year: " + year.daysElapsed(day, month));
System.out.println("Days elapsed in a Leap Year: " + leapyear.daysElapsed(day, month));
}
}
LeapYear2.java
public class LeapYear extends Year
{
//Constructor for class
public LeapYear2()
{
//Setting number of days
setNumberofdays(366);
}
//Method to get end value
public int daysElapsed(int day, int month)
{
int temp = 0;
for (int i = 1; i < month;i++);
{
if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)
{
temp += 31;
}
else if (i == 4 || i == 6 || i == 9 || i == 11)
{
temp += 30;
}
else if (i == 2)
{
temp += 29;
}
}
temp += day;
return temp;
}
}
Year2.java
public class Year2
{
int numberofdays;
public void getNumberofdays()
{
System .out.println(numberofdays);
}
public void setNumberofdays(int numberofdays)
{
this.numberofdays = numberofdays;
}
public Year2()
{
setNumberofdays(365);
}
public int daysElapsed(int day, int month)
{
int temp = 0;
for (int i = 1; i < month;i++);
{
if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)
{
temp += 31;
}
else if (i == 4 || i == 6 || i == 9 || i == 11)
{
temp += 30;
}
else if (i == 2)
{
temp += 28;
}
}
temp += day;
return temp;
}
}
Solution
HI, I have fixed all error.
Please let me know in case of any issue.
######## Year.java #######
public class Year
{
//Variable
private int numberofdays;
//Constructor for Year class
public Year()
{
setNumberofdays(365);
}
public int getNumberofdays()
{
return numberofdays;
}
//Method to set the value
public void setNumberofdays(int numberofdays)
{
this.numberofdays = numberofdays;
}
}
################## LeapYear.java ############
public class LeapYear extends Year
{
//Constructor for class
public LeapYear()
{
//Setting number of days
setNumberofdays(366);
}
//Method to get end value
public int daysElapsed(int day, int month)
{
int temp = 0;
for (int i = 1; i < month;i++)
{
if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)
{
temp += 31;
}
else if (i == 4 || i == 6 || i == 9 || i == 11)
{
temp += 30;
}
else if (i == 2)
{
temp += 29;
}
}
temp += day;
return temp;
}
}
######### UseYear.java ###############
public class UseYear
{
public static void main(String args[])
{
//Initializing class
Year year = new Year();
//Calling method to display days
System.out.println(year.getNumberofdays());
//Initializing class
LeapYear leapyear = new LeapYear();
//Calling to display days
System.out.println(leapyear.getNumberofdays());
}
}

More Related Content

Similar to Please help me find my errors. I am lost as I know what the problem.pdf

Functional C++
Functional C++Functional C++
Functional C++
Kevlin Henney
 
Java Lab Manual
Java Lab ManualJava Lab Manual
Java Lab Manual
Naveen Sagayaselvaraj
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
MaruMengesha
 
The real beginner's guide to android testing
The real beginner's guide to android testingThe real beginner's guide to android testing
The real beginner's guide to android testing
Eric (Trung Dung) Nguyen
 
Presentacion clean code
Presentacion clean codePresentacion clean code
Presentacion clean code
IBM
 
Jeremiah Caballero - Introduction of Clean Code
Jeremiah Caballero - Introduction of Clean CodeJeremiah Caballero - Introduction of Clean Code
Jeremiah Caballero - Introduction of Clean Code
Awesome Ars Academia
 
Structure and Interpretation of Test Cases
Structure and Interpretation of Test CasesStructure and Interpretation of Test Cases
Structure and Interpretation of Test Cases
Kevlin Henney
 
Java22_1670144363.pptx
Java22_1670144363.pptxJava22_1670144363.pptx
Java22_1670144363.pptx
DilanAlmsa
 
Software design principles SOLID
Software design principles SOLIDSoftware design principles SOLID
Software design principles SOLID
Foyzul Karim
 
Java™ (OOP) - Chapter 10: "Thinking in Objects"
Java™ (OOP) - Chapter 10: "Thinking in Objects"Java™ (OOP) - Chapter 10: "Thinking in Objects"
Java™ (OOP) - Chapter 10: "Thinking in Objects"
Gouda Mando
 
Test Time Bombs
Test Time BombsTest Time Bombs
Test Time Bombs
Wojciech Bulaty
 
05. Java Loops Methods and Classes
05. Java Loops Methods and Classes05. Java Loops Methods and Classes
05. Java Loops Methods and Classes
Intro C# Book
 
enum_comp_exercicio01.docx
enum_comp_exercicio01.docxenum_comp_exercicio01.docx
enum_comp_exercicio01.docx
Michel Valentim
 
Initial Java Core Concept
Initial Java Core ConceptInitial Java Core Concept
Initial Java Core Concept
Rays Technologies
 
ES2015 workflows
ES2015 workflowsES2015 workflows
ES2015 workflows
Jarrod Overson
 
15. DateTime API.ppt
15. DateTime API.ppt15. DateTime API.ppt
15. DateTime API.ppt
VISHNUSHANKARSINGH3
 
Basic Java Application Developer Sesi 2
Basic Java Application Developer Sesi 2Basic Java Application Developer Sesi 2
Basic Java Application Developer Sesi 2
Rudi Hartono
 
Java Programs
Java ProgramsJava Programs
Java Programs
vvpadhu
 

Similar to Please help me find my errors. I am lost as I know what the problem.pdf (20)

Functional C++
Functional C++Functional C++
Functional C++
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
 
Java Lab Manual
Java Lab ManualJava Lab Manual
Java Lab Manual
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
 
The real beginner's guide to android testing
The real beginner's guide to android testingThe real beginner's guide to android testing
The real beginner's guide to android testing
 
JavaProgrammingManual
JavaProgrammingManualJavaProgrammingManual
JavaProgrammingManual
 
Presentacion clean code
Presentacion clean codePresentacion clean code
Presentacion clean code
 
Jeremiah Caballero - Introduction of Clean Code
Jeremiah Caballero - Introduction of Clean CodeJeremiah Caballero - Introduction of Clean Code
Jeremiah Caballero - Introduction of Clean Code
 
Structure and Interpretation of Test Cases
Structure and Interpretation of Test CasesStructure and Interpretation of Test Cases
Structure and Interpretation of Test Cases
 
Java22_1670144363.pptx
Java22_1670144363.pptxJava22_1670144363.pptx
Java22_1670144363.pptx
 
Software design principles SOLID
Software design principles SOLIDSoftware design principles SOLID
Software design principles SOLID
 
Java™ (OOP) - Chapter 10: "Thinking in Objects"
Java™ (OOP) - Chapter 10: "Thinking in Objects"Java™ (OOP) - Chapter 10: "Thinking in Objects"
Java™ (OOP) - Chapter 10: "Thinking in Objects"
 
Test Time Bombs
Test Time BombsTest Time Bombs
Test Time Bombs
 
05. Java Loops Methods and Classes
05. Java Loops Methods and Classes05. Java Loops Methods and Classes
05. Java Loops Methods and Classes
 
enum_comp_exercicio01.docx
enum_comp_exercicio01.docxenum_comp_exercicio01.docx
enum_comp_exercicio01.docx
 
Initial Java Core Concept
Initial Java Core ConceptInitial Java Core Concept
Initial Java Core Concept
 
ES2015 workflows
ES2015 workflowsES2015 workflows
ES2015 workflows
 
15. DateTime API.ppt
15. DateTime API.ppt15. DateTime API.ppt
15. DateTime API.ppt
 
Basic Java Application Developer Sesi 2
Basic Java Application Developer Sesi 2Basic Java Application Developer Sesi 2
Basic Java Application Developer Sesi 2
 
Java Programs
Java ProgramsJava Programs
Java Programs
 

More from fathimahardwareelect

Which one of the following is NOT a social trend that is currently af.pdf
Which one of the following is NOT a social trend that is currently af.pdfWhich one of the following is NOT a social trend that is currently af.pdf
Which one of the following is NOT a social trend that is currently af.pdf
fathimahardwareelect
 
Which of the following is normally a major activity of materials man.pdf
Which of the following is normally a major activity of materials man.pdfWhich of the following is normally a major activity of materials man.pdf
Which of the following is normally a major activity of materials man.pdf
fathimahardwareelect
 
What is the role of civil society in promoting democracySolutio.pdf
What is the role of civil society in promoting democracySolutio.pdfWhat is the role of civil society in promoting democracySolutio.pdf
What is the role of civil society in promoting democracySolutio.pdf
fathimahardwareelect
 
What mechanism causes plant ion-uptake to acidify soilSolution.pdf
What mechanism causes plant ion-uptake to acidify soilSolution.pdfWhat mechanism causes plant ion-uptake to acidify soilSolution.pdf
What mechanism causes plant ion-uptake to acidify soilSolution.pdf
fathimahardwareelect
 
using the knowledge about experiments that are related to plant g.pdf
using the knowledge about experiments that are related to plant g.pdfusing the knowledge about experiments that are related to plant g.pdf
using the knowledge about experiments that are related to plant g.pdf
fathimahardwareelect
 
True or False Justify your answer.The concept of flooding is alwa.pdf
True or False Justify your answer.The concept of flooding is alwa.pdfTrue or False Justify your answer.The concept of flooding is alwa.pdf
True or False Justify your answer.The concept of flooding is alwa.pdf
fathimahardwareelect
 
True or False. If H is a subgroup of the group G then H is one of it.pdf
True or False.  If H is a subgroup of the group G then H is one of it.pdfTrue or False.  If H is a subgroup of the group G then H is one of it.pdf
True or False. If H is a subgroup of the group G then H is one of it.pdf
fathimahardwareelect
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
fathimahardwareelect
 
Immunizations that the elderly need to receive on a yearly basis inc.pdf
Immunizations that the elderly need to receive on a yearly basis inc.pdfImmunizations that the elderly need to receive on a yearly basis inc.pdf
Immunizations that the elderly need to receive on a yearly basis inc.pdf
fathimahardwareelect
 
Question 11 Scarcity means O people need to use marginal analysis to .pdf
Question 11 Scarcity means O people need to use marginal analysis to .pdfQuestion 11 Scarcity means O people need to use marginal analysis to .pdf
Question 11 Scarcity means O people need to use marginal analysis to .pdf
fathimahardwareelect
 
Question 2 Sba Do you know something about the Statement Of Financ.pdf
Question 2 Sba Do you know something about the Statement Of Financ.pdfQuestion 2 Sba Do you know something about the Statement Of Financ.pdf
Question 2 Sba Do you know something about the Statement Of Financ.pdf
fathimahardwareelect
 
Question 1. give the CC++ code that defines an empty 5 element arra.pdf
Question 1. give the CC++ code that defines an empty 5 element arra.pdfQuestion 1. give the CC++ code that defines an empty 5 element arra.pdf
Question 1. give the CC++ code that defines an empty 5 element arra.pdf
fathimahardwareelect
 
List and explain all the components of company culture.Jackson, S..pdf
List and explain all the components of company culture.Jackson, S..pdfList and explain all the components of company culture.Jackson, S..pdf
List and explain all the components of company culture.Jackson, S..pdf
fathimahardwareelect
 
Please write 5-6 setences about each emotional intelligence capabili.pdf
Please write 5-6 setences about each emotional intelligence capabili.pdfPlease write 5-6 setences about each emotional intelligence capabili.pdf
Please write 5-6 setences about each emotional intelligence capabili.pdf
fathimahardwareelect
 
Negligence and intentional torts are subject to civil litigation as .pdf
Negligence and intentional torts are subject to civil litigation as .pdfNegligence and intentional torts are subject to civil litigation as .pdf
Negligence and intentional torts are subject to civil litigation as .pdf
fathimahardwareelect
 
Incuded within the major CPI basket groups are various government-cha.pdf
Incuded within the major CPI basket groups are various government-cha.pdfIncuded within the major CPI basket groups are various government-cha.pdf
Incuded within the major CPI basket groups are various government-cha.pdf
fathimahardwareelect
 
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdfIdentify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
fathimahardwareelect
 
How many grams of solid NaCN have to be added to 1.4 L of water to d.pdf
How many grams of solid NaCN have to be added to 1.4 L of water to d.pdfHow many grams of solid NaCN have to be added to 1.4 L of water to d.pdf
How many grams of solid NaCN have to be added to 1.4 L of water to d.pdf
fathimahardwareelect
 
How does Warhol add to the semiotic statement of the readymadeS.pdf
How does Warhol add to the semiotic statement of the readymadeS.pdfHow does Warhol add to the semiotic statement of the readymadeS.pdf
How does Warhol add to the semiotic statement of the readymadeS.pdf
fathimahardwareelect
 
How do I add a ComboBox to this, underneath Enter Student ID tha.pdf
How do I add a ComboBox to this, underneath Enter Student ID tha.pdfHow do I add a ComboBox to this, underneath Enter Student ID tha.pdf
How do I add a ComboBox to this, underneath Enter Student ID tha.pdf
fathimahardwareelect
 

More from fathimahardwareelect (20)

Which one of the following is NOT a social trend that is currently af.pdf
Which one of the following is NOT a social trend that is currently af.pdfWhich one of the following is NOT a social trend that is currently af.pdf
Which one of the following is NOT a social trend that is currently af.pdf
 
Which of the following is normally a major activity of materials man.pdf
Which of the following is normally a major activity of materials man.pdfWhich of the following is normally a major activity of materials man.pdf
Which of the following is normally a major activity of materials man.pdf
 
What is the role of civil society in promoting democracySolutio.pdf
What is the role of civil society in promoting democracySolutio.pdfWhat is the role of civil society in promoting democracySolutio.pdf
What is the role of civil society in promoting democracySolutio.pdf
 
What mechanism causes plant ion-uptake to acidify soilSolution.pdf
What mechanism causes plant ion-uptake to acidify soilSolution.pdfWhat mechanism causes plant ion-uptake to acidify soilSolution.pdf
What mechanism causes plant ion-uptake to acidify soilSolution.pdf
 
using the knowledge about experiments that are related to plant g.pdf
using the knowledge about experiments that are related to plant g.pdfusing the knowledge about experiments that are related to plant g.pdf
using the knowledge about experiments that are related to plant g.pdf
 
True or False Justify your answer.The concept of flooding is alwa.pdf
True or False Justify your answer.The concept of flooding is alwa.pdfTrue or False Justify your answer.The concept of flooding is alwa.pdf
True or False Justify your answer.The concept of flooding is alwa.pdf
 
True or False. If H is a subgroup of the group G then H is one of it.pdf
True or False.  If H is a subgroup of the group G then H is one of it.pdfTrue or False.  If H is a subgroup of the group G then H is one of it.pdf
True or False. If H is a subgroup of the group G then H is one of it.pdf
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
 
Immunizations that the elderly need to receive on a yearly basis inc.pdf
Immunizations that the elderly need to receive on a yearly basis inc.pdfImmunizations that the elderly need to receive on a yearly basis inc.pdf
Immunizations that the elderly need to receive on a yearly basis inc.pdf
 
Question 11 Scarcity means O people need to use marginal analysis to .pdf
Question 11 Scarcity means O people need to use marginal analysis to .pdfQuestion 11 Scarcity means O people need to use marginal analysis to .pdf
Question 11 Scarcity means O people need to use marginal analysis to .pdf
 
Question 2 Sba Do you know something about the Statement Of Financ.pdf
Question 2 Sba Do you know something about the Statement Of Financ.pdfQuestion 2 Sba Do you know something about the Statement Of Financ.pdf
Question 2 Sba Do you know something about the Statement Of Financ.pdf
 
Question 1. give the CC++ code that defines an empty 5 element arra.pdf
Question 1. give the CC++ code that defines an empty 5 element arra.pdfQuestion 1. give the CC++ code that defines an empty 5 element arra.pdf
Question 1. give the CC++ code that defines an empty 5 element arra.pdf
 
List and explain all the components of company culture.Jackson, S..pdf
List and explain all the components of company culture.Jackson, S..pdfList and explain all the components of company culture.Jackson, S..pdf
List and explain all the components of company culture.Jackson, S..pdf
 
Please write 5-6 setences about each emotional intelligence capabili.pdf
Please write 5-6 setences about each emotional intelligence capabili.pdfPlease write 5-6 setences about each emotional intelligence capabili.pdf
Please write 5-6 setences about each emotional intelligence capabili.pdf
 
Negligence and intentional torts are subject to civil litigation as .pdf
Negligence and intentional torts are subject to civil litigation as .pdfNegligence and intentional torts are subject to civil litigation as .pdf
Negligence and intentional torts are subject to civil litigation as .pdf
 
Incuded within the major CPI basket groups are various government-cha.pdf
Incuded within the major CPI basket groups are various government-cha.pdfIncuded within the major CPI basket groups are various government-cha.pdf
Incuded within the major CPI basket groups are various government-cha.pdf
 
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdfIdentify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
 
How many grams of solid NaCN have to be added to 1.4 L of water to d.pdf
How many grams of solid NaCN have to be added to 1.4 L of water to d.pdfHow many grams of solid NaCN have to be added to 1.4 L of water to d.pdf
How many grams of solid NaCN have to be added to 1.4 L of water to d.pdf
 
How does Warhol add to the semiotic statement of the readymadeS.pdf
How does Warhol add to the semiotic statement of the readymadeS.pdfHow does Warhol add to the semiotic statement of the readymadeS.pdf
How does Warhol add to the semiotic statement of the readymadeS.pdf
 
How do I add a ComboBox to this, underneath Enter Student ID tha.pdf
How do I add a ComboBox to this, underneath Enter Student ID tha.pdfHow do I add a ComboBox to this, underneath Enter Student ID tha.pdf
How do I add a ComboBox to this, underneath Enter Student ID tha.pdf
 

Recently uploaded

How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 

Recently uploaded (20)

How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 

Please help me find my errors. I am lost as I know what the problem.pdf

  • 1. Please help me find my error/s. I am lost as I know what the problem is but not sure how to fix it. Problem: Exception in thread "main" java.lang.Error: Unresolved compilation problems: The method getNumberofdays() is undefined for the type Year The method getNumberofdays() is undefined for the type LeapYear at UseYear.main(UseYear.java:11) UseYear.java public class UseYear { public static void main(String args[]) { //Initializing class Year year = new Year(); //Calling method to display days year.getNumberofdays(); //Initializing class LeapYear leapyear = new LeapYear(); //Calling to display days leapyear.getNumberofdays(); } } LeapYear.java public class LeapYear extends Year { //Constructor for LeapYear class public LeapYear() { setNumberofdays(366); } } Year.java public class Year { //Variable int numberofdays;
  • 2. public void getNumberofdays { System.out.println(numberofdays); } //Method to set the value public void setNumberofdays(int numberofdays) { this.numberofdays = numberofdays; } //Constructor for Year class public Year() { setNumberofdays(365); } } UseYear2.java public class UseYear2 { public static void main(String args[]) { int day = 2, month = 3; //Initializing class Year2 year = new Year2(); //Initializing class LeapYear2 leapyear = new LeapYear2(); //Display days elapsed System.out.println("Days elapsed in a Year: " + year.daysElapsed(day, month)); System.out.println("Days elapsed in a Leap Year: " + leapyear.daysElapsed(day, month)); } } LeapYear2.java public class LeapYear extends Year { //Constructor for class public LeapYear2() {
  • 3. //Setting number of days setNumberofdays(366); } //Method to get end value public int daysElapsed(int day, int month) { int temp = 0; for (int i = 1; i < month;i++); { if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) { temp += 31; } else if (i == 4 || i == 6 || i == 9 || i == 11) { temp += 30; } else if (i == 2) { temp += 29; } } temp += day; return temp; } } Year2.java public class Year2 { int numberofdays; public void getNumberofdays() { System .out.println(numberofdays); } public void setNumberofdays(int numberofdays)
  • 4. { this.numberofdays = numberofdays; } public Year2() { setNumberofdays(365); } public int daysElapsed(int day, int month) { int temp = 0; for (int i = 1; i < month;i++); { if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) { temp += 31; } else if (i == 4 || i == 6 || i == 9 || i == 11) { temp += 30; } else if (i == 2) { temp += 28; } } temp += day; return temp; } } Solution HI, I have fixed all error. Please let me know in case of any issue. ######## Year.java #######
  • 5. public class Year { //Variable private int numberofdays; //Constructor for Year class public Year() { setNumberofdays(365); } public int getNumberofdays() { return numberofdays; } //Method to set the value public void setNumberofdays(int numberofdays) { this.numberofdays = numberofdays; } } ################## LeapYear.java ############ public class LeapYear extends Year { //Constructor for class public LeapYear() { //Setting number of days setNumberofdays(366); } //Method to get end value public int daysElapsed(int day, int month) { int temp = 0; for (int i = 1; i < month;i++) { if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) {
  • 6. temp += 31; } else if (i == 4 || i == 6 || i == 9 || i == 11) { temp += 30; } else if (i == 2) { temp += 29; } } temp += day; return temp; } } ######### UseYear.java ############### public class UseYear { public static void main(String args[]) { //Initializing class Year year = new Year(); //Calling method to display days System.out.println(year.getNumberofdays()); //Initializing class LeapYear leapyear = new LeapYear(); //Calling to display days System.out.println(leapyear.getNumberofdays()); } }