• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

Boolean method- main method

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hello, I am writing a program where the user has to input values and then it checks if they are eligible or not. If they are eligible the program should ask the following questions, if not it should run an error. I was wondering if you could help me find my error
 
Marshal
Posts: 71098
292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please start by indenting your code correctly; it is difficult to read like that.
Please use legible variable names; coun and country are confusing, especially if put close together. And why are you calling a boolean cost?
You can call different methods after each input to validate the input.
You won't get Scanner#nextLine() to work after nextInt(). What have you ben taught about nextLine()?
 
jack miles
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


So, what can I call instead nextInt() for the age value.
 
Master Rancher
Posts: 3723
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Aside from that... we seem to have only part of the method, so it's hard to tell what you're doing here.

What problem are you having currently with nextInt()?  Does your program compile?  Does it print a stack trace?  Does it behave incorrectly?  Please describe the problem you're currently having.
 
jack miles
Greenhorn
Posts: 5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand it is because I copy pasted my work that's why, but I figure it out. My mistake was that I forget to put reader.nextline(); after  int age = reader.nextInt();
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic