File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How do I print a division symbol and parenthesis? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do I print a division symbol and parenthesis?" Watch "How do I print a division symbol and parenthesis?" New topic
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: 11170
    
  16

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: /");


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
Don't get me started about those stupid light bulbs.
 
subject: How do I print a division symbol and parenthesis?
 
Similar Threads
NumberFormat does not display negatives correctly
PropertyChangeEvent
1.5 Integer with +=
operator precedence
compiler error in the Party.java on page 3