#confused with methods
1 messages · Page 1 of 1 (latest)
While you are waiting for getting help, here are some tips to improve your experience:
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.
@rigid beacon
yes
I think you should take input first
System.out.print("Enter city name and population");
String var1 =scnr.next() ;
String var2=scnr.next() ;
PrintCitySize(var1, var2) ;
I think this should work
hello?
How do you know it doesn't work?
Did you get an error?
becasue System.out.print("Enter city name and population"); this is not the output that i want
yes i got two errors
Delete it then 🙂
What's your code and what output do you get?
Do you know what Scanner does?
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)