Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java Code

Options
  • 21-05-2013 2:01pm
    #1
    Registered Users Posts: 9


    Just wondering can anyone shed any light on this for me and how to do it .






    Create a Java Program called Bools using eclipse or any IDE
    Declare 2 Boolean variables b1 and b2, one value true and other false
    Output these values
    Declare a third Boolean variable b3 and set it to be the reverse of value of true Boolean variable
    Output reversed variable
    Use an expression to set value of Boolean b3 equal to b1 OR b2 (logical OR)
    Output b3
    Use the parseBoolean method to input a String value (either true or false)and translates it into a
    real Boolean b4.
    Output b3 AND b4 (logical AND)


Comments

  • Registered Users Posts: 710 ✭✭✭mad turnip


    have you read anything on java before?


  • Moderators, Sports Moderators, Regional Abroad Moderators Posts: 2,642 Mod ✭✭✭✭TrueDub


    Show us what you've done so far & we'll help. We won't do it for you though.


  • Registered Users Posts: 185 ✭✭gaelicyoda


    Sounds suspiciously like a class 101 assignment :)


  • Registered Users Posts: 710 ✭✭✭mad turnip


    gaelicyoda wrote: »
    Sounds suspiciously like a class 101 assignment :)

    That was my first thought XD


  • Registered Users Posts: 9 BLACK OP


    Its the part to variable b3 and set it to be the reverse of value of true Boolean variable .Does this mean its just set as fales


  • Advertisement
  • Registered Users Posts: 9 BLACK OP


    sorry did not ask the question right


  • Registered Users Posts: 9 BLACK OP


    public class Bools {

    public static void main(String[] args) {

    /*
    * boolean is simple Java type which can have only of two values; true or false.
    * All rational expressions retrun this type of value.
    *
    * Declare boolean varibale as below
    *
    * boolean <variable name> = <default value>;
    *
    * here assigning default value is optional.
    */

    boolean b1 = true;
    boolean b2 = false;
    boolean b3 = false;

    System.out.println("Value of bools variable b1 is :" + b1);
    System.out.println("Value of bools variable b2 is :" + b2);
    System.out.println("Value of bools variable b3 is :" + b3);
    }
    }

    /*
    Output would be
    Value of boolean variable b1 is :true
    Value of boolean variable b2 is :false
    Value of boolean variable b3 is :false
    */


  • Registered Users Posts: 9 BLACK OP


    is this right with this park of the question Declare a third Boolean variable b3 and set it to be the reverse of value of true Boolean variable


  • Registered Users Posts: 428 ✭✭[Rasta]


    To set the b3 as inverse of b1, you can use the ! operator.


  • Registered Users Posts: 710 ✭✭✭mad turnip


    so for a code example it would be
    b3 = !b1;


  • Advertisement
  • Registered Users Posts: 9 BLACK OP


    Ah thanks new i was not seeing it


Advertisement