Results 1 to 3 of 3
Thread: Boolean help
- 11-20-2011, 01:36 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 26
- Rep Power
- 0
Boolean help
Sorry for asking to many questions. Am needing to implement boolean logic (or so i think) and was wondering how i go about doing this.
The boolean is for the else if statement. I need a system.in but no sure how to implement boolean.Java Code:public class InnerInsulation { boolean yes, no; public InnerInsulation() { yes = true; no = false; Scanner in = new Scanner(System.in); CheckColour cl = new CheckColour(); if (cl.getUserColour() == 0 || cl.getUserColour() == 1) { System.out.println("Inner insulation is not available for the number of colour(s) choosen"); } else if (cl.getUserColour() == 2) { System.out.println("Would you like insulation?"); } } }
All help will be appreciated.
- 11-20-2011, 01:46 PM #2
Senior Member
- Join Date
- Nov 2010
- Posts
- 210
- Rep Power
- 3
Re: Boolean help
Do you mean you want to get input from the user, and set a boolean variable to true for yes and false for no?
If so, the variables yes and no are unnecessary. Try something like this:
Does that make sense?Java Code:String input = in.nextLine(); boolean wantsInsulation = (input.equalsIgnoreCase("Y") || input.equalsIgnoreCase("YES");
- 11-20-2011, 01:56 PM #3
Member
- Join Date
- Nov 2011
- Posts
- 26
- Rep Power
- 0
Similar Threads
-
Boolean.True and Boolean.False, why do some people use these?
By Pojahn_M in forum New To JavaReplies: 3Last Post: 09-13-2011, 12:01 AM -
boolean error help when no boolean is given
By drewtrcy in forum New To JavaReplies: 18Last Post: 05-05-2011, 09:04 AM -
boolean even or odd?
By shazakala in forum New To JavaReplies: 3Last Post: 04-17-2011, 08:02 AM -
Boolean help
By DMarsh12 in forum New To JavaReplies: 8Last Post: 04-11-2011, 09:41 PM -
use boolean as 0 or 1
By joost_m in forum New To JavaReplies: 10Last Post: 04-13-2010, 11:22 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks