• 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Why isnt this condition running?  RSS feed

 
Ranch Hand
Posts: 423
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have this question to do

Design and implement a program that will accept a person’s age, number of year driving, and whether or not they drink. The program will determine whether they are eligible for car insurance or not. A person under 22 is not eligible. People 22 and up to 30 are eligible if they do not drink and are driving 3 years or more. People over 30 are eligible if they have at least 6 years driving experience. You need to display an appropriate message to the person who is applying for insurance.

its all working except for over 30 which seems to be running the first if for some reason can somebody please help me understand what is wrong

here is my code

also can somebody tell me how efficient this code is...and how would be the best way to write this...thanks


 
author & internet detective
Posts: 38917
686
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jon,
This line of code has an error in it:
<br /> <br /> It says that if the drivers age is greater than/equal to 22 or less than/equal to 30. "or" means that either condition must be true. So if driverAge is 55, we have <br /> 55 >= 22 or 55 <= 30
true or false
true
 
jon ninpoja
Ranch Hand
Posts: 423
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks jeanne

yes changed or to and ...its working perfect now
so the and checks it as 1 condition
but or is allowing different results in right?

whats up with all the <b> </br> etc never seen it before
 
Marshal
Posts: 61766
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

jon ninpoja wrote:. . . whats up with all the <b> </br> etc never seen it before

Don't know, but we are looking at it. I wouldn't know how to correct it mysefl.
 
Jeanne Boyarsky
author & internet detective
Posts: 38917
686
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

jon ninpoja wrote:so the and checks it as 1 condition
but or is allowing different results in right?


Right!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!