• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why isnt this condition running?

 
Ranch Hand
Posts: 424
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic