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!
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?
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.
Re: confused on what this problem is asking for (bitwise operators)
Quote:
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?