Program Output Display Tweak Help

Reply

Join Date: Jun 2005
Posts: 4
Reputation: CoolHandLuke is an unknown quantity at this point 
Solved Threads: 0
CoolHandLuke CoolHandLuke is offline Offline
Newbie Poster

Program Output Display Tweak Help

 
0
  #1
Jun 21st, 2005
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.
Attached Files
File Type: java InteractiveCalculator.java (5.2 KB, 6 views)
File Type: java BigInt.java (8.5 KB, 9 views)
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Program Output Display Tweak Help

 
0
  #2
Jun 22nd, 2005
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.
  1. textField.setHorizontalAlignment(JTextField.CENTER);
  2. or .RIGHT
  3. or .LEFT
  4. or .LEADING
  5. or .TRAILING
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 3
Reputation: compiler is an unknown quantity at this point 
Solved Threads: 0
compiler compiler is offline Offline
Newbie Poster

Re: Program Output Display Tweak Help

 
0
  #3
Jul 11th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 3
Reputation: compiler is an unknown quantity at this point 
Solved Threads: 0
compiler compiler is offline Offline
Newbie Poster

Re: Program Output Display Tweak Help

 
0
  #4
Jul 11th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Program Output Display Tweak Help

 
0
  #5
Jul 11th, 2005
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.
I don't have time to run everyone's code. If you do, that's great. About your second comment, I just now looked at the code and saw that he's using the command line to run this.d
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 45
Reputation: cheenu78 is an unknown quantity at this point 
Solved Threads: 0
cheenu78's Avatar
cheenu78 cheenu78 is offline Offline
Light Poster

Re: Program Output Display Tweak Help

 
0
  #6
Jul 12th, 2005
hi compiler

I have changed your code at a couple of places.
try running your code and tell me is this what was in your mind?

regards
Srinivas
Attached Files
File Type: java BigInt.java (8.5 KB, 3 views)
File Type: java InteractiveCalculator.java (5.2 KB, 3 views)
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 3
Reputation: compiler is an unknown quantity at this point 
Solved Threads: 0
compiler compiler is offline Offline
Newbie Poster

Re: Program Output Display Tweak Help

 
0
  #7
Jul 20th, 2005
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC