Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I print a division symbol and parenthesis?

 
Jeff Ciaccio
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Duc Vo
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's wrong with using the characters directly?
"To get the balance point type this into your calculator: \n " + a +"/ (1 - "+a+")"
 
Jeff Ciaccio
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12198
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: /");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic