Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: confused on what this problem is asking for (bitwise operators)

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default confused on what this problem is asking for (bitwise operators)

    Write a program that prompts for an integer that is stored in variable format. The program should:
    1. "turn on" the boldface, italics, and underlining features.
    2. determine, for each feature, whether the feature is on or off and print true or false, indicating on or off. Use five println statements to do this. Hint: Use another bitwise operator to determine the value of a bit. This trick is called masking.
    3. "turn off" underlining and "turn on" subscripting, and strikethrough.
    4. print true or false, indicating the values of the underline, subscript, and strikethrough bits.

    I think it wants me to use the bits, but I'm not sure what exactly to write. My book lists the bit codes for bold, italics, etc. I also have to use the bitwise operators to turn them on, but I'm not sure I know what to do. Does the integer prompted have to be one of the 1, 2, 4, 8, or 16? Or can it be any integer and I have to format it?

    The output is supposed to look like:
    boldface: true
    italics: true
    underline: true
    subscript: false
    strikethrough: false

    underline: false
    subscript: true
    strikethrough: true

    Do I need to get the final bits to look like 00000111 for the first and then the second part would be 00011000?
    I'm not asking anyone to write it for me, just maybe clarify the directions. Thanks for the help!


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: confused on what this problem is asking for (bitwise operators)

    What kind of program is this? The GUI type display settings: subscripting, and strikethrough. etc don't look like java features.
    Is this a javascript problem?

  3. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: confused on what this problem is asking for (bitwise operators)

    Supposedly, it is. Some of the code it provides is along the lines of

    final int BOLDFACE = 1; //00000001
    final int ITALICS = 2; //00000010
    final int UNDERLINE = 4; //00000100
    final int SUBSCRIPT = 8; //00001000
    final int STRIKETHROUGH = 16; //00010000

    I'm not sure exactly what they want, though.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: confused on what this problem is asking for (bitwise operators)

    I'm not sure exactly what they want, though.
    What kind of program is this? The GUI type display settings: subscripting, and strikethrough. etc don't look like java features.
    Is this a javascript problem?

Similar Threads

  1. Confused..
    By jadowers in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 5th, 2011, 12:56 PM
  2. Evaluation of operators in expressions.
    By TP-Oreilly in forum Java Theory & Questions
    Replies: 7
    Last Post: September 23rd, 2011, 07:23 PM
  3. BITWISE
    By bitwise11 in forum The Cafe
    Replies: 0
    Last Post: January 25th, 2011, 01:09 PM
  4. Logical Operators
    By truebluecougarman in forum Java Theory & Questions
    Replies: 3
    Last Post: January 22nd, 2011, 06:26 PM
  5. Need Help with Operators/ logic
    By codekiller in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 3rd, 2010, 09:25 AM