#How to fix an error where the compiler cannot find the symbol which is the method within a println?

68 messages · Page 1 of 1 (latest)

hazy beacon
#

error: cannot find symbol
System.out.println("Enter your homework average: " + getHomeworkAverage());
The method is "getHomeworkAverage()" but the compiler is unable to find it. I am new to Java so I might be doing this totally wrong.

hollow gorge
#

Where did you define that method?

brave condor
#

what does getHomeworkAverage() return?
Maybe you return a symbol thats not available in vanilla java? 😄

hazy beacon
hazy beacon
hollow gorge
#

this.getHomeworkAverage()?

hazy beacon
#

???

hollow gorge
#

???

hazy beacon
#

It doesn't work

hazy beacon
#

Better question

#

How do I print a method from a class?

#

OH

hazy beacon
#

Never mind, I can't solve it

atomic cairnBOT
#

ℹ️ @hazy beacon this post has been closed. Feel free to reopen it if you have any further questions.

hazy beacon
#

um

#

@hollow gorgeAm I allowed to ask a different question for the same program here or do I have to create a new post?

hazy beacon
#

well

#

right now, I am having trouble getting a method to print out correctly

#

It only prints as "0.0"

#

So I thought about converting int into double but nothing changed

#

public void setExamAverage(double examAverage)
{
double exam1Score = exam1;
double exam2Score = exam2;
double exam3Score = exam3;
examAverage = (exam1Score + exam2Score + exam3Score) / 3;
}

public double getExamAverage()
{
return examAverage;
}

public void setOverallAverage(double overallAverage)
{
double homeworkAverage = homework;
double quizAverage = quiz;
overallAverage = 015 * homeworkAverage + 0.15 * quizAverage + 0.70 * examAverage;
}

public double getOverallAverage()
{
return overallAverage;
}

cedar crag
hollow gorge
#

homie gotta yoink the this.examAverage

hazy beacon
hollow gorge
hazy beacon
hazy beacon
hollow gorge
#

same thing

hazy beacon
#

setExamAverage() gets 3 exam scores from user input and then it gets the average
getExamAverage() returns it
setOverallAverage() takes the homework and quiz averages from the user and the exam average then gets the overall average
getOverallAverage() returns it

hollow gorge
#

setExamAverage
then it gets the average
wher set

hazy beacon
#

Where set?

hollow gorge
#

you call it set average

#

where does it set the average

hazy beacon
#

In setExamAverage()? There other previous methods that gets the homework average, quiz average, and 3 exam scores and they all should work

hollow gorge
#

Where do you set anything in there

#

you just reassign the parameter

hazy beacon
#

public int getExamScore1()
{
System.out.println("Enter your grade on the first exam: ");
int getExamScore1 = scanner.nextInt();
System.out.println(getExamScore1);
return exam1;
}

#

What do you mean "reassign it"?

hollow gorge
#

what

hazy beacon
#

I don't know

#

This language is too confusing for me

#

C# is not going to confuse me too if I am having trouble with Java, right?

cedar crag
#

They're the same language for the most part

hollow gorge
#

you can take a Java dev and have them write C# in like a few days

hazy beacon
#

So far, C# is easy

#

But I haven't learn much code

cedar crag
hazy beacon
#

I am using this.examAverage

#

Seems to work just fine without it

cedar crag
#

In setExamAverage you assign to the parameter (examAverage) rather than the field (this.examAverage), which is going to do nothing.

hazy beacon
#

I removed all parameters and nothing has changed

cedar crag
#

Then open a debugger and see where the problem lies because it's not in assigning that value.

#

Most debuggers will give you a breakdown of all fields and their values.

hazy beacon
#

I don't have a debugger

cedar crag
#

What do you use to write Java?

#

Cuz the main IDEs have debuggers built in.

hazy beacon
#

TextPad

cedar crag
#

😒

hazy beacon
#

So why does it keep printing 0.0?

cedar crag
#

How are this.exam1, this.exam2, and this.exam3 assigned?

cedar crag
hazy beacon
#

this.homework = homework;
this.quiz = quiz;
this.exam1 = exam1;
this.exam2 = exam2;
this.exam3 = exam3;
this.examAverage = examAverage;
this.overallAverage = overallAverage;

cedar crag
#

But where. Would be easier to get a whole class rather than just fragments.

hazy beacon
#

Scanner scanner = new Scanner(System.in);

private int homework, quiz, exam1, exam2, exam3;
        double examAverage, overallAverage;

public Class()
{
    this.homework = homework;
    this.quiz = quiz;
    this.exam1 = exam1;
    this.exam2 = exam2;
    this.exam3 = exam3;
    this.examAverage = examAverage;
    this.overallAverage = overallAverage;
}
hazy beacon
#

Without user input, the method still prints 0.0