+ 1
Java methods
Someone pls help, i dont know what is wrong with my program. https://code.sololearn.com/cykmt5czfxWN/?ref=app
11 ответов
+ 3
I would say it is the use of multiple Scanner objects.
To get rid of them, you have multiple possibilities:
1) use a static field Scanner keyboard in the Painter class.
2) pass the Scanner object to the methods that use them
3) read all input in main and pass the values to the methods (if they need them)
+ 3
APURVA KAUSHAL
Please create a new question for your problem. Thanks!
+ 2
nevermind, i figured it out. thanks for all your help
+ 1
It might be caused by creating two Scanners opening the same System.in stream. Don't instantiate new Scanner in the method when you already opened the stream with other one in the main body
+ 1
remove the Scanner in roomArea()
pass the already created one to the function.
//call
dim=roomArea(keyboard);
//definition
public static double roomArea(Scanner keyboard )
{
//Scanner keyboard=new Scanner(System.in);
double dim;
System.out.print("Enter the total area of walls: ");
dim=keyboard.nextDouble();
System.out.print("Dimension: "+dim+ "sq ft");
return dim;
}
+ 1
Bobby Dike
And here is an example where Scanner keyboard is a static variable:
https://code.sololearn.com/c27OzbgJtzeD/?ref=app
0
can you please re write my code, i dont know how to do these
0
Denise Roßberg Mikolaj Agnes Ahlberg Bahha🐧
the second method in my program does not work as its supposed to.
0
Bobby Dike
Can you give an input/output example and describe how it should work?
0
could you stick around? I might need extra help in a few.
0
I cant solve time converter how to solve it ?