• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Why isnt this condition running?  RSS feed

 
Ranch Hand
Posts: 424
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: 39234
727
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: 424
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: 64089
215
  • 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: 39234
727
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!
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!