+ 1
Outputting a method, Java
Please I need help, emergency đł Please show me how to correct line 43: https://sololearn.com/compiler-playground/cABwV8ZWSRsl/?ref=app
9 Answers
+ 6
I don't think the error is where you think it is...
For starters, you have a println with your cal.Xxx() which should call the switch method and that has println statements inside it... are you expecting to println a println?
Rethink your code - maybe take out a pen and paper and draw/write what it should do, how should the input be called, passed and handled?
Then, I think you'll fix it.
+ 5
your code is unnecessarily complicated...
why does everything have to be separate classes?
OOP is best kept simple. Implementing it this way is just extra work with no benefit. And the current trend for more efficient code is to move away from OOP.
+ 3
Code Flash Your GiveAnswer() is a void function(doesn't return anything, simply does tasks and uses println). But you're trying to output its returned value by using println(cal.GiveAnswer()). Since your function already outputs values, you don't need to use println. As Ausgrindtube said, you're trying to println a println. Simply call the function, no need to use println to call it.
And I'd suggest you to take the Java course and learn about functions and return values. You should check it before creating codes like this, as you'll be stuck.
+ 2
PrintAnswer.java:9: error: <identifier> expected
System.out.println(^cal.GiveAnswer());
> so look at fields of that class:
class PrintAnswer extends Calculate {
Calculate cal = new Calculate(); // first field ok
System.out.println(cal.GiveAnswer()); // second, .. wait, that's not a field !
/* println() should be in some method(),
else compiler expects field identifier */
}
+ 1
Ausgrindtube I couldn't find a replacement for println, please can you tell me the solution đ
+ 1
I appreciate your work, and I would like to request to study the OOPS principle clearly and then do the program. It's not following the principle. Also, you must know the main method. That's where all the program starts.
+ 1
2 errors
+ 1
I really think this is a Rube Goldberg machine (https://en.wikipedia.org/wiki/Rube_Goldberg_machine), but if you must extend classes, maybe this way:
https://sololearn.com/compiler-playground/cd4g5pnJIbXA/?ref=app
0
Hey but I learned methods and I'm currently in java intermediate with my other sololearn account, I just got stock, am I being underestimated because this account is just in level 3?