Outputting BigInteger Results one line at a time

hi all,
im new to this. im havin problems with my code. i was to read into two Bigintegers and multi[ply them.. but with the multiplication i want to show each line as it is being done and send it to the screen. as u can see from the code i was hopin to do it in two parts. the first gettin the result and the second just workin it out line by line. is this a good way to do it?  i was tryin to read the last digit and work up to the work up to the first but i cant do it. here is a snippet of the calucatations.. i really hope someone can help cause im really stuck at this point
thanks a million
al.
BigInteger num1 = new BigInteger(textAreaNum1.getText());
    BigInteger num2 = new BigInteger(textAreaNum2.getText());
    result = num1.multiply(num2);
    totalDigit = num2;
    currDigit= num2;
    for (BigInteger ix = BigInteger.ZERO; ix.compareTo(totalDigit) < 0; ix = currDigit.add(BigInteger.ONE))
      currResult = currDigit.multiply(num1);
      textAreaCalculation.setText("" + num1 + "" + zeroAdder);
textAreaResult.setText(""+ result);
// the resultin screen should look like
// 234
// *123
// 702
// 4680
// 23400
// 28782

this is my program as it stands but with another class callin the frame.. so u want me to change the textfield to jtextfield?
package Mulitply;
import java.awt.*;
import java.awt.event.*;
import java.math.BigInteger;
import javax.swing.JTextArea.*;
* Title: Mulitplier of Large Numbers
* Description: This class extends the application class and add all
* all the data below to it. it basically sets up the frame
* in terms of look,feel and action.
* Copyright: Copyright (c) 2004
* Company:
* author
* version 1.0
class CalcFrame extends Frame implements ActionListener{
Button btnMult;
TextField textAreaNum1, textAreaNum2, textAreaCalculation, textAreaResult;
public CalcFrame() {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
setSize(1000, 300);
setTitle("Mulitpler");
setLayout(new FlowLayout());
setBackground(Color.lightGray);
Panel pnlNums = new Panel();
Panel pnlBtns = new Panel();
Panel pnlCalculation = new Panel();
Panel pnlResult = new Panel();
setLayout(new GridLayout(3, 1));
textAreaNum1 = new TextField(50);
textAreaNum2 = new TextField(50);
pnlNums.add(textAreaNum1);
pnlNums.add(textAreaNum2);
btnMult = new Button("*");
btnMult.addActionListener(this);
pnlBtns.add(btnMult);
textAreaCalculation = new TextField(50);
textAreaResult = new TextField(50);
pnlResult.add(textAreaResult);
pnlCalculation.add(textAreaCalculation);
add(pnlNums);
add(pnlBtns);
add(pnlCalculation);
add(pnlResult);
public void actionPerformed(ActionEvent e) {
String str1 = textAreaNum1.getText().trim();
String str2 = textAreaNum2.getText().trim();
int len1 = str1.length();
int len2 = str2.length();
if ( (len1 == 0) || (len2 == 0))
return;
BigInteger num1 = new BigInteger(str1);
BigInteger num2 = new BigInteger(str2);
BigInteger result = num1.multiply(num2);
String resultStr = result.toString();
int resultLen = resultStr.length();
textAreaCalculation.setText("");
textAreaCalculation.append(str1 + "\n");
textAreaCalculation.append("*" + str2 + "\n");
textAreaCalculation.append(pad(resultLen, "--") + "\n");
BigInteger ten = new BigInteger("10");
for (int i = (len2 - 1); i >= 0; i--) {
BigInteger curNum = new BigInteger(str2.substring(i, i + 1));
BigInteger curRes = curNum.multiply(num1);
for (int j = 0; j < len2 - 1 - i; j++)
curRes = curRes.multiply(ten);
String curResStr = curRes.toString();
int curResLen = curResStr.length();
textAreaCalculation.append(pad(resultLen - curResLen, "--") + curResStr + "\n");
textAreaCalculation.append(pad(resultLen, "--") + "\n");
textAreaCalculation.append(resultStr + "\n");
String pad(int n, String s) {
String ret = "";
for (int i = 0; i < n; i++)
ret += s;
return ret;
}

Similar Messages

  • Utility to send text file over GPIB, one line at a time?

    We are developing instrumentation that receives data and commmands over GPIB as plain text, and returns them as well. I'd like to create GPIB "batch" files and send them over the bus, one line at a time, so I can debug the instruments' behavior. I'd also like to be able to read back responses, one line at a time.
    Is there such a utility? I've got our programmer working on something like this, but I'd hate to have him re-invent an existing wheel.
    Thanks!

    Apart from NI-SPY, I have not heard of such a utility. This may be simple to implement using proper termination. If the instrument is capable of sending line feeds or carriage return, you should be able to easily create a document. Also, using IBWRTF, you could write the ASCII file (containing the termination characters) to the bus. Depending on how you have your timeouts specified, this may be ideal.
    Alternately, if you read a static amount of data, you could IBRD chunks of data. the result may need editing for broken words at the end of a line but would achieve such a result.
    Ryan Mosley
    National Instruments, Applications Engineer
    http://www.ni.com/exchange

  • How can I display one line at a time on a PPT slide

    I am using OFFICE for the Mac (2008).
    In the past, I have known how to do this using PPT on a Windows PC..
    But something has changed and I can no longer figure out how to get each line on a PPT slide to appear one line at a time every time I click it.
    It's not that difficult, but I can't figured out where they moved the "Appear" option.
    I am NOT using KEYNOTE, but PowerPoint from OFFICE for the Mac (2008)
    Can someone help me.
    Thanks,
    Tom

    Since this is a Keynote discussion forum, there may be no one here that knows. I personally hate PP and could care less about how to make one line display at a time. It is easy on Keynote and that is all I need to know. You might want to look for a PP forum and ask there.

  • How do I scroll more than one line at a time in Firefox 4? Scrolling with down-up keyboard arrows is much faster in IE/Chrome.

    I have tried using about:config options mousewheel.withnokey.sysnumlines > false and custom set mousewheel.withnokey.numlines, but it makes a difference only when I use a mouse, which I don't use most of the time on this laptop. I use down/up keyboard errors to scroll, and the page scrolls one-line-at-a-time, very slow and lagging. Is there a way around this?
    I have reinstalled Chrome as secondary browser only because of this, FF4 otherwise really kicksass. Thank you for an amazing browser and any feedback on my issue.

    Well I am using those, but it is not very practical. What puzzles me is that only Firefox has this behaviour, I have tried last versions of IE, Chrome, Opera - all three scroll much faster than Firefox 4 using down/up keyboard arrows.
    Thanks for the reply, I really hope to get a solution to this.

  • How do I scroll one line at a time in Lion?

    I want to upgrade to Lion but need the functionality of the scroll bar arrows. I have learned that the functionality of the arrows is part of the core operating system and is not being replaced. Any suggestions as to any add-on devices that would allow this function?
    Thanks,
    Rich

    If the program/window is not a text-based one (such as a word processor), you can usually use the up and down arrow keys to scroll up or down one line at a time.
    There are often mods to this behavior, but exactly what depends on the program. Test with the up and down arrow keys in conjunction with the usual modifier keys - Shift, Command, Option, etc.

  • Reading in one line at a time.

    How can I read one line at a time?
    String sData = "One large string"
    StringReader reader = new StringReader(sData);
    StringBuffer buf = new StringBuffer();
    String line = "";
    while ((line = reader.toString()) != null) {//This line does not read one line at a time. Is it possible to do the with StringReader?
    StringTokenizer tok = new StringTokenizer(line, "|");
    Thanks:0)

    The following code snippet does what you want :-)
            String test = new String("testString \n with \n multiple lines");
            StringReader strReader = new StringReader(test);
            BufferedReader strBufRdr = new BufferedReader(strReader);
            String line = null;
            try {
                while((line=strBufRdr.readLine())!=null) {
                    System.out.println(line);
            catch(IOException e) { System.out.println(e); }Have fun!

  • Make image appear one line at a time

    I have an image of a seashell that I created in Photoshop.
    It's just black and white outline of an image. What I want to do is
    reveal this seashell image one line at a time. I tried creating
    motion paths but only part of the image is visible at any given
    time, the image doesn't get revealed toward the end. Any help would
    be greatly appreciated.
    To give an idea of what I mean, this link here will show
    that:
    http://www.flashforwardconference.com/past_winners
    . Once on the page click on the link "Type Drawing" next to the
    words Typography:
    Thank you,
    ar

    I'd suggest masking the image layer and then using whatever
    form of animation (tweens, brute force, etc) works best to reveal
    the image through the mask. If the image is organic in nature (and
    assuming that you don't just want to reveal it top to bottom like a
    scan) then probably hand drawing onto the mask frame-by-frame is
    the best way (although this adds a lot of keyframes).

  • Fillable pdf's returned by clients are readable only one line at a time

    We have been emailing fillable pdf questionnaires to our customers for them to complete and return via email.  When some of them have come
    back, they are only viewable one line at a time, we need to highlight the fillable field that the customer completed so we can view their answer.
    Does anyone know why this occurs and why it would be isolated to a few cases?  Thanks!
    George

    They were probably filled-in and saved with the Preview application on the Mac. For more information and some approaches you can take to correct, see: http://kb2.adobe.com/community/publishing/885/cpsid_88564.html

  • Photo printing slow one line at a time

    My first time printing phots on my Officejet 4620 and it is taking 20 minutes per picture one line at a time. Very frustrated. Call the help line and was told tht how this printer works.....

    Many things can affect printing photos. Wireless connectivity (if applicable), paper size, print quality, software used to print the photo, printer design optimization (photo printer vs. office printer), security software used on your computer,  etc.....
    That being said, this photo printing document may offer some information of benefit:
    http://www.hp.com/united-states/consumer/digital_photography/print_better_photos/tips/printer-settin...
    007OHMSS
    I was a support engineer for HP.
    If the advice resolved the situation, please mark it as a solution. Thank you.

  • Listbox one line at a time

    I want to add one line at a time in listbox/textbox just like InsertTextboxLine funtion in CVI. I can not find similar VI in labview. I think I can do it long way...by saving listbox to an array then append my line at the end of the array and send updated array to listbox..these are lot of steps to add one line to listbox/textbox...
    Any help would be appreciated.
    Thanks.
    CVI 2010
    LabVIEW 2011 SP1
    Vision Builder AI 2011 SP1

    Actually, the way to append an item to a list box is to create an Item Names property node for the list box.  Then you can use Insert Into Array, and write to another property node for Item Names.
    Message Edited by tbob on 10-03-2005 02:31 PM
    - tbob
    Inventor of the WORM Global
    Attachments:
    ListBox.PNG ‏3 KB

  • Why does pressing the down arrow button result in going to the bottom of the page and being nunable to go up or down one line at a time?

    i dont know what to say in way of clarification. when looking at a page i am forced to use the "slide" on the margin which is very sensitive on very long documents instead of the down arrow to move one line. pressing the arrow results in going to the bottom and you cant return using the arrow.

    The arrow to open the tab history of the Back and Forward buttons has been removed in Firefox 4 and later.
    Use one of these methods to open the tab history list:
    * Right click on the Back or Forward button
    * Hold down the left mouse button on the enabled Back or Forward button until the list opens
    You can look at this extension:
    * Backward Forward History Dropdown: https://addons.mozilla.org/firefox/addon/backforedrop/

  • Sending output to just one line

    I'm trying to get a guy script together to help view the indexes of our deployment wim files out of a folder.  I'm getting there, but, stuck at a point.  This is my first attempt at scripting, so, I'm a bit new and ignorant...  please forgive
    me...
    I can get the list of wim files, select the wim file, and get the output how I want, except, only one object at a time...  for example...
    $objWimListBox.Add_Click(
    $cmdlet = $objWimListBox.SelectedItem
    $wimfiles = Invoke-Expression "Get-WindowsImage -ImagePath c:\$cmdlet"
    $objIndexListBox.Items.Clear()
    if ($wimfiles –ne $Null)
    foreach ($index in $wimfiles)
    [Void] $objIndexListBox.Items.Add($index.ImageIndex) + $objIndexListBox.Items.Add($index.ImageDescription)
    gives the output of:
    1
    W7x86Laptop
    2
    W7x86Desktop
    3
    W7x86TermClient
    4
    W7x86Basic
    Where as I am wanting the output to be:
    1 W7x86Laptop
    2 W7x86Desktop
    3 W7x86TermClient
    4 W7x86Basic
    I want the index number to be on the same line as the description, so I can select the line and pass the selection on to my next bit of code...
    What am I missing here?  

    # the correct way to add a collection to a listbox
    $cmdlet = $objWimListBox.SelectedItem
    $wimfiles=Get-WindowsImage -ImagePath "c:\$cmdlet"
    $objIndexListBox.DisplayMember='ImageDescription'
    $objIndexListBox.DataSource=[System.Collections.ArrayKist]$wimFiles
    #In the selection event get the image
    $wimfile=$objIndexListBox.SelectedItem
    ¯\_(ツ)_/¯

  • My mouse scrolls shows each line moving up instead of moving one line at a time annoying

    Since downloading firefox 3.6 when I scroll down a page it shows each line moving up instead of just moving one line up its very annoying

    It could be that there is not enough memory in the printer or the print server to hold the entire document while printing. The printer gets Postscript files, which are larger than the original document. Also, if you are doing multiple copies, if you collate the pages, that takes more memory than printing each page multiple times.

  • How do I get Firefox to go back to scrolling one line at a time with the up/down arrow keys? I noticed this changed in Firefox 10 and I actually preferred the one line at a time, can this be an option in future releases?

    The title says it all, I'm not really sure if this is the proper place to post this as it's not a "bug" per se. I noticed on the list of bugs "fixed" in Firefox 10 scrolling more than one line with the arrow keys was one of them. I know a lot of people hated the one-line thing too so I'd suggest in future releases it should be a preference we can change.

    You can right-click either Back or Forward button to open the tab history list.

  • Why has my hp deskjet 2050 printer and scanner suddenly slowed down and printing one line at a time

    why has my hp deskjet 2050  printer and scanner suddenly slowed down and printing one line at a time

    This is usually indicative of a defective print cartridge.  Suspect the black is low in ink or defective.  Please check all cartridges. 
    Say thanks by clicking the Kudos Thumbs Up to the right in the post.
    If my post resolved your problem, please mark it as an Accepted Solution ...
    I worked for HP but now I'm retired!

Maybe you are looking for

  • Problem with Adobe Updater

    Recently reinstalled CS3.  On first opening the system pulled down updates.  These won't install.  The updater is caught in a perpetual circle of trying to update and stopping.  My instinct tells me this is something simple but I can't find a clue an

  • Outbound Proxy messages in SXI_MONITOR of R/3 system in status "Scheduled"

    Hi guys, I have the following issue: In a Proxy-to-File Scenario, we are trying to send some data from R/3, but they never reach XI because they remain in sender R/3 system, transaction SXI_MONITOR with status "Scheduled", with a green flag. I cannot

  • Art work randomly displaying or not syncing.

    Touch 1.1.3 (with software update) ITunes 7.6 on Vista Home Premium. The vast majority of my albums have synced fine but for some the Touch doesn't display the artwork regardless of orientation being landscape or portrait. For the one's it doesn't wa

  • Partitioning Question

    How does a range-hash partition work with a local index? I have rebuilt my sales table which was range partitioned by ORDER_DATE (with local index on ORDER_DATE). The new sales table is now range partitioned by ORDER_DATE with 4 hash sup partitions o

  • Safari keeps closing web pages, quitting on new iPad Air?

    Any ideas?