| | |
Program Output Display Tweak Help
![]() |
•
•
Join Date: Jun 2005
Posts: 4
Reputation:
Solved Threads: 0
I have attached 2 java files which, when run, simulate a calculator that performs addition and multiplication only. I have been working on it for some time...getting assistance from varioius sources. I am having two issues I need help in correcting. They are as follows:
1) When multiplying two single digit numbers...a leading zero is attached
to the bottom digit (num2) I wish to remedy this by either removing it
for single digits or add a zero to the top digit (num1). I'm referring
to the output display.
2) When the output is displayed...the top number (num1) is shifted to
much to the right. I would like for it to be a bit more uniform.
I am trying to learn JAVA and this is my first attempt at a program other than the example from "JAVA for Dummies!" lol. Thanks in advance.
1) When multiplying two single digit numbers...a leading zero is attached
to the bottom digit (num2) I wish to remedy this by either removing it
for single digits or add a zero to the top digit (num1). I'm referring
to the output display.
2) When the output is displayed...the top number (num1) is shifted to
much to the right. I would like for it to be a bit more uniform.
I am trying to learn JAVA and this is my first attempt at a program other than the example from "JAVA for Dummies!" lol. Thanks in advance.
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
You'll have to explain the 1st question a little more.
One the second question, if you are using a JTextField to display data, you can set the horizontal alignment.
One the second question, if you are using a JTextField to display data, you can set the horizontal alignment.
Java Syntax (Toggle Plain Text)
textField.setHorizontalAlignment(JTextField.CENTER); or .RIGHT or .LEFT or .LEADING or .TRAILING
•
•
Join Date: Jul 2005
Posts: 3
Reputation:
Solved Threads: 0
Can you enhance your program with adding and subtracting method as well? I'd love to see the complete calculator if you dont mind. The program occurs because of your display method. You'll need to add some code to check if the preceeding number is 0, it has to be gotten rid of before being printed out to the screen.
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
•
•
•
•
Originally Posted by compiler
To server_crash, you will understand the first question if you try to run the program with some trial input. About the second question, I dont think your answer is helpful at all.
•
•
Join Date: Jul 2005
Posts: 3
Reputation:
Solved Threads: 0
You succeed in get rid of the leading Zero in the output. That's great. But what I am trying to do is come up with a better algorithm for the muliplication method. When I entered a 10 digit number times another 8 digit number, it would take like forever to get the answer. There's a huge Big O for the efficiency of this program.
![]() |
Similar Threads
- letter p (C)
- Time display program (C++)
- water program using subprograms (Computer Science)
Other Threads in the Java Forum
- Previous Thread: Unrelated Java
- Next Thread: Cant figure out second half of piramid
| Thread Tools | Search this Thread |
2dgraphics account android api apple applet application arguments array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class client code color component count database derby design eclipse eclipsedevelopment encryption error fractal game givemetehcodez graphics gridlayout gui homework html ide if_statement image integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel jtextfield julia keyword linux list macintosh map method methods midlethttpconnection mobile netbeans newbie nullpointerexception object open-source os problem producer program programming project projectideas property read recursion reference replaysolutions ria scanner search server set size sms sort sourcelabs splash sql sqlite stop string swing threads transforms tree ui unicode validation windows






