#confused with methods

1 messages · Page 1 of 1 (latest)

drifting rootBOT
#

<@&987246717831381062> please have a look, thanks.

drifting rootBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

terse saffron
#

@rigid beacon

rigid beacon
#

yes

terse saffron
#

I think you should take input first

rigid beacon
#

wdym

#

im so confsued

#

what

terse saffron
#

System.out.print("Enter city name and population");
String var1 =scnr.next() ;
String var2=scnr.next() ;
PrintCitySize(var1, var2) ;

#

I think this should work

rigid beacon
#

? but var 2 is a int

#

that doesnt work

rigid beacon
#

hello?

random aurora
rigid beacon
#

i tried that code in the system

#

and it didnt work

random aurora
#

Did you get an error?

rigid beacon
#

becasue System.out.print("Enter city name and population"); this is not the output that i want

#

yes i got two errors

rigid beacon
#

i did

#

still does not give me the output that i want

random aurora
#

What's your code and what output do you get?

rigid beacon
random aurora
#

Do you know what Scanner does?

signal rampart
#

Your input is a single String e.g. "Ottawa Philadelphia 934243 1526006"

#

What you need to do is parse that String and print your expected output

#

to accept user input use nextLine instead of next and you only need to run this once.

#

For the rest you need to figure out how to extract the information from the input text (hint: String has a split method)