Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Currently I am working on some java and ran across this problem of trying to format my code correctly onto one line. I have set the first group of numbers assigned to the variable stored as a String `string1` the second group of numbers to `string2`and my last group of numbers to `string3`. Currently I am outputting these numbers to a txt so that is what the `output.print();` is doing. What I want is a plus sign in-between the first set of numbers and a equal sign in-between the last set of numbers. Currently when I print out these numbers it looks more like this ---
-20 -32
 -12 -9
  + 4 2
 2 1
  = -16 -30
 -10 -8


However I would like my output to look like this by them being seperated together and of course with a + and = sign between the groups of numbers.
-20 -32     4 2     -16 -30
-12 -9      2 1     -10 -8



output.print(string1 + " + " + string2 + " = " string3);


If you guys could give me some input on how I could fix this that would be great! Thank you!

What I have tried:

I have tried this
output.print(string1 + " + " + string2 + " = " string3)

However this did not give the output I was hoping for.
Posted
Updated 10-Apr-17 22:27pm
Comments
wseng 10-Apr-17 22:56pm    
We need to see the part of the codes that you used.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900