| Author |
How do I print a division symbol and parenthesis?
|
Jeff Ciaccio
Greenhorn
Joined: Nov 26, 2008
Posts: 25
|
|
I am trying to use the ASCII characters to add a division symbol and open & closed parenthesis, but this is not printing correctly.
a is a variable, and the calculation is: a / (1 - a)
Do I just have the wrong codes? Should I be looking up decimal or hex?
Thanks
|
Jeff Ciaccio, Java novice <br />Physics and AP Physics Teacher<br />Sprayberry High School <br />Marietta, GA
|
 |
Duc Vo
Ranch Hand
Joined: Nov 20, 2008
Posts: 254
|
|
What's wrong with using the characters directly?
"To get the balance point type this into your calculator: \n " + a +"/ (1 - "+a+")"
|
“Everything should be as simple as it is, but not simpler.” Albert Einstein
|
 |
Jeff Ciaccio
Greenhorn
Joined: Nov 26, 2008
Posts: 25
|
|
I did not realize I could use parenthesis in quotes, but I would like to show the division symbol to show students which key to press on their calculators.
Thanks
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9956
|
|
assuming you want to print a '\' character, you have to know that it has special meaning inside parens. usually it means "hey, treat the next character as something special" - as in the case of "\n" means "treat the 'n' as a 'newline' character". This is commonly referred to an "escaped n". the backslash is referred to as the escape character.
so how to you print the escape character? you ESCAPE IT!!!
System.out.println("this will print a single backslash: \\)";
if you want a single frontslash, you can just print it:
System.out.println("this will print a single frontslash: /");
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
 |
|
|
subject: How do I print a division symbol and parenthesis?
|
|
|