Help increment through array elements to print

I am to create an amortization program to list the month, year, payment, interest, and balance. Everything works except the year increments by 1 on every loop (it should increment only when month is January), and the array of months prints the entire 12 months in one column. I need to print one month then tab to the year, then the rest. Here is a sample output.
Mortgage Payments
Financial Details
Loan Amount: $200,000.00
Payment Amount: $1,167.15
Term (in years) 30
Term (in months) 360
Interest Rate: 5.75%
Payments are $1,167.15 per month
Month Year Payment Amount Interest Amount Balance
January
February
March
April
May
June
July
August
September
October
November
December
monthcount =1 // some variable I added to watch monthcount...will remove later
2004 $1,167.15 $607.89 $198,832.85
January
February
// and it starts over
Here is the method to create array:
void printBody() {
finalyear = printyear + TERM;
do {
balance = balance - payment;
intAmount = payment - (payment * RATE) * 100;
DecimalFormat dollarFmt = new DecimalFormat("$###,###.00");
MortgagePmt prtmo = new MortgagePmt();
String monthPrint[] = {
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December" };
for (int i = 0; i < monthPrint.length; i++)
System.out.println("\n" + monthPrint);
++monthcount;
if (printmonth < 2)
++printyear;
System.out.println("monthcount =" + monthcount);
System.out.println("\t" + printyear + "\t" + dollarFmt.format(payment)
+ "\t" + dollarFmt.format(intAmount) + "\t" + dollarFmt.format(balance));
while (monthcount <= finalyear && balance <= AMOUNT && monthcount <= totmonths);
Then, I simply call "printBody()" from Main.
I want the output to be:
January 2004 $1,167.15 $607.89 $198,832.85
February 2004 $1,167.15 $607.89 $19x,xxxx,xx
and so on.... for the life of the 30 year mortgage.
Can anyone give me an idea of what to do to accomplish this? I started out originally using case statements (each month was a different case); however, I couldn't figure out how to make the case increment because it would only print one element each time. Same problem.
Any help would be greatly appreciate. It's for my Java class and I am stuck!

use a loop and
while(i < 360)
   System.out.println(value);
i++;

Similar Messages

  • Help on changing array elements with For loop

    Hi,
    I'm wondering if anyone can help me with this problem.  I'd like to be able to modify elements of an array with For loop.  In the attached VI, my goal is to have an array of [0 1 2 3 4 5], but instead what I've got is [2 2 2 2 4 5].  I initialized the array with a value of 2 to help me identify which elements are changing.  Can anyone help me pointing where my mistake is?  Thanks.
    Peter
    Attachments:
    Array test.vi ‏19 KB

    It's a classic issue for LV newbies. In this case you HAVE to use a
    shift register otherwise the modifications of previous cicles are lost.
    It's all easier than it's seems, see attached vi.
    bye,
    manga
    Attachments:
    Array test 2.vi ‏19 KB

  • My 2D Array is only printing one of the elements

    Hello,
    My 2D array is only printing one of the elements and I was wondering if someone can help me figure out why. I want this program to simply print the value and position in the matrix. An example output would be
    0,0 0,1 0,2
    1,0 1,1 1,2
    2,0 2,1 2,2
    Thanks.
    public class PrintArrayPositions1 {
        public static void main (String[]args){
         /* The number sectors in array */
         int M = Integer.parseInt(args[0]);
         int N = Integer.parseInt(args[1]);
         //create an array to store value and position in.
         int[][]count = new int[M][N];
         /*/  array to record results/*/
         for(int i=0; i<count.length; i++){
             for(int j=0; j<count.length; j++){
              count[i][j]= i + j;
              System.out.print(" " + count[i][j] + " ");
         System.out.println();

    count[i][j] prints the sum of row and column, which is not what you want i think...
    for(int i=0; i<count.length; i++){
             for(int j=0; j<count.length; j++){                                           
              System.out.print(i+","+j+" ");
         System.out.println();

  • Going through all elements in array

    Hi there,
    This problem has been getting to me and I know the answer is right in front of my face, so just wondering if someone can help point it out for me?
    I have a folder of files (txt, tdms, etc) and my code is set up to report back all the files on the folder and number of files as an array. Then I want to be able to go through each element 1 by 1 and use each sepearte element later on.
    The idea is I will have a folder where new files are constantly saved and I was this program to check the folder (in case it has been updated) and then for me to be able to use the new files as well. (eventually i will assign each element in the array to the end of a path so that each file will be called as the system goes through the array).
    I've tried this with a for loop, as in standard text based programming that is the go to way but when I run it like this in labview, it doesnt look like the system is running through the array. Is this just becaus eit is happening so fats,, it wont show on the front panel or have I missed something? I have attached the code
    Kelly
    Attachments:
    ArrayElements.vi ‏9 KB

    Kelly,
    accessing each individual item in the array is possible by using an "auto-indexing" input tunnel. Right-click your input-tunnel and select "Enable Indexing" for this. It is rather strange that it is not already like this as for for-loops, auto-indexing is default. Please note that with auto-indexing input-tunnels, you don't need to conntect the "N" terminal. Also, the "Index Array" function in the loop is not necessary as well (in fact, it will create a wiring error).
    Output-tunnels is the same... but in your provided example, the code will be "Rube Goldberg" as it does nothing else then to copy the array if you configure the output-tunnel to be auto-indexing. So this only makes sense, if you add some analysis functions in the loop which modify specific elements.
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Incrementing through instances of movieclips to get them into an array

    I have a form with a bunch of questions.  With each question, the user needs to select an answer from a dropdown list.  I am then creating  an array that will store the answer to each question when the user clicks the submit button.  Each of the drop down menus is named sequentially.  So what I am trying to do is write  a while loop that will increment through and read each of the values into the array so I can process the responses later.  The issue that I am having is writing the syntax to recognize the Instance name of the specific drop down I am trying to reference.
    Here is the basic code I am using:
    var Store:Array = new Array(2);
    public var Increment:Number;
    Increment = 1;
    while (Increment <=2){
    Store[Increment] = MovieClip(Scroller2.Form_Scroller.content).DropDown1.value;
    trace(Store);
    Increment++;
    So the DropDowns instance names are DropDown1, DropDown2 etc…  It works fine if I manually enter in each instance name (but there are 43 total and I don’t want to do each one individually).  
    I am assuming that I need to setup some sort of variable to temporarily add the increment number to the “DropDown” and then use that as the reference:
    Increment = 1;
    while (Increment <=2){
                    ItemNumber = "DropDown" + Increment;
                    Store[Increment] = MovieClip(Scroller2.Form_Scroller.content).ItemNumber.value;
    trace(Store);
    Increment++;
    But when I do that, I get the following error message:
    TypeError: Error #1010: A term is undefined and has no properties.
                    at combotest/submitted()
    I assume this is because it is looking for an instance of ItemNumber instead of the instance of the value of ItemNumber.  So how do I get it to look for that?
    I have attached the test files.
    Steve

    try:
    var Store:Array = new Array(2);
    public var Increment:Number;
    Increment = 1;
    while (Increment <=2){
    Store[Increment] = MovieClip(Scroller2.Form_Scroller.content)["DropDown"+Increment].value;
    trace(Store);
    Increment++;

  • I can not print my e-mail through Firefox, I can print attachment is ok. Please help

    I can not print e-mail through Firefox, I can print from Google or IE, I tried about:config and reset, I am still having same problem.

    What happens when you try to print: do you get an error message, or a blank/jumbled page, or just nothing?
    If you are using an email site that offers a special print-formatted page, this usually opens in a pop-up window. Is there a problem with the window not opening?

  • How to change the color of Numeric array elements (seperatel​y) programmat​ically using property node??

    For example, i have 3 numeric controls, controlling 3 numeric array elements (Numeric control is connected directly to indicator). Then if i change value in numeric control 1, then the array element No.1 of numeric array should turn red when value exceeds 5. Similarly when i change num control 2 then element 2 of array should turns red when value in num control 1 exceeds 10. Similarly for 3rd element. In other words, i want to control the property of array elements individually through seperate numeric control.
    I have done it for single numeric indicator.i.e. when i change numeric control's values then a single numeric indicator changes values and color (Numeric text BG property) but with array, the color of whole array changes but i want to change color of singles element of array.
    Please help thanks.  
    Solved!
    Go to Solution.

    ...or replace the numerics with clusters that have a numeric and a color box. make the background of the nmeric transparent and slide the color box behind the numeric. Use the color box to control the background color.
    Other alternatives would use a cluster instead of the array or if your req's are really weird "roll-your-own" with a Picture control.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Need help with adding arrays to invoice.java please willing to pay?

    Using your Invoice class created in lab02, write a client program that allows the user to input three Invoice objects into an array of Invoice objects. After you have inputted all of the invoices, print a heading and then output all of the array elements (Invoice objects) by calling the method from your Invoice class that displays all of the data members on a single line using uniform field widths to insure that all Invoice objects will line up in column format (created in Lab04). At the end of the loop, display the calculated total retail value of all products entered in the proper currency format.
    Example of possible program execution:
    Part Number : WIDGET
    Part Description : A fictitious product
    Quantity : 100
    Price          : 19.95
    (etc.)
    Example of possible output
    Part Number          Part Description          Quantity          Price     Amount
    WIDGET          A fictitious product     100          19.95     199.95
    Hammer               9 pounds          10          5.00     50.00
    (etc.)
    Total Retail Value:                                   249.95
    This is what i have so far Invoice Test
    //Lab 2 InvoiceTest.java
    //Application to test class Invoice.
    //By Morris Folkes
    public class InvoiceTest
    public static void main( String args[] )
    Invoice invoice1 = new Invoice( "1234", "Hammer", 2, 14.95 );
    // display invoice1
    System.out.println( "Original invoice information" );
    System.out.printf( "Part number: %s\n", invoice1.getPartNumber() );
    System.out.printf( "Description: %s\n",
    invoice1.getPartDescription() );
    System.out.printf( "Quantity: %d\n", invoice1.getQuantity() );
    System.out.printf( "Price: %.2f\n", invoice1.getPricePerItem() );
    System.out.printf( "Invoice amount: %.2f\n",
    invoice1.getInvoiceAmount() );
    // change invoice1's data
    invoice1.setPartNumber( "001234" );
    invoice1.setPartDescription( "Blue Hammer" );
    invoice1.setQuantity( 3 );
    invoice1.setPricePerItem( 19.49 );
    // display invoice1 with new data
    System.out.println( "\nUpdated invoice information" );
    System.out.printf( "Part number: %s\n", invoice1.getPartNumber() );
    System.out.printf( "Description: %s\n",
    invoice1.getPartDescription() );
    System.out.printf( "Quantity: %d\n", invoice1.getQuantity() );
    System.out.printf( "Price: %.2f\n", invoice1.getPricePerItem() );
    System.out.printf( "Invoice amount: %.2f\n",
    invoice1.getInvoiceAmount() );
    Invoice invoice2 = new Invoice( "5678", "PaintBrush", -5, -9.99 );
    // display invoice2
    System.out.println( "\nOriginal invoice information" );
    System.out.printf( "Part number: %s\n", invoice2.getPartNumber() );
    System.out.printf( "Description: %s\n",
    invoice2.getPartDescription() );
    System.out.printf( "Quantity: %d\n", invoice2.getQuantity() );
    System.out.printf( "Price: %.2f\n", invoice2.getPricePerItem() );
    System.out.printf( "Invoice amount: %.2f\n",
    invoice2.getInvoiceAmount() );
    // change invoice2's data
    invoice2.setQuantity( 3 );
    invoice2.setPricePerItem( 9.49 );
    // display invoice2 with new data
    System.out.println( "\nUpdated invoice information" );
    System.out.printf( "Part number: %s\n", invoice2.getPartNumber() );
    System.out.printf( "Description: %s\n",
    invoice2.getPartDescription() );
    System.out.printf( "Quantity: %d\n", invoice2.getQuantity() );
    System.out.printf( "Price: %.2f\n", invoice2.getPricePerItem() );
    System.out.printf( "Invoice amount: %.2f\n",
    invoice2.getInvoiceAmount() );
    } // end main
    } // end class InvoiceTest

    i suck in java There are 2 possible reasons for this:
    1. you haven't studied
    2. you aren't cut out for programming
    and there r hardly any tutors at my school. plus i work 2 jobs day n night. Please, I'm only want help thats allYou have the help of the ENTIRE WORLD COMMUNITY right here, right now. But you're not willing to make any effort whatsoever. You think people will help or even respect you? You may fail your class and you may fail in life!
    Cheaters don't win and winners don't cheat!

  • Display a particular array element on the front panel

    Hello,
    I was wondering if it's possible to change which element of an array control is displayed on the front panel from within the program.
    Here's why I want to do it: I have an array of clusters, each of which contains a set of controls.  The controls in each cluster specify a bunch of different parameters for a few different instruments that are being controlled by Labview.  The user changes all the values on the front panel before the program starts, then the program steps through the array elements one by one.  I'd like to be able to change the array's display so that the user can know which set of parameters is active (and thus what is currently in force) while the program is going -- otherwise the element that is displayed is just wherever the user left it last.
    Thanks in advance for any help.

    See also: http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=317419#M317419
    LabVIEW Champion . Do more with less code and in less time .

  • Need help on object array, please.

    Hello. I'm trying to write a program that stores student id numbers and their names into an array, and then prints them in numerical order. What I did was create an object called DSCC and put it in an array, but I'm having problems. Everytime I run this I get a null pointer exception, here is my code.
    public class Main {
      public Main() {
      public void getStudenInfo(String Number1, String Name, int Number){
        Number1 = JOptionPane.showInputDialog("Enter student number, 999 to quit");
        Number = Integer.parseInt(Number1);
        if(Number != 999){
          Name = JOptionPane.showInputDialog("Enter student name");
      public void putInArray(DSCC ded[], String na, int nu){
          ded[0].studentname = na;
          ded[0].studentnumber = nu;
           System.out.println(ded[0]);
      public void printList(){
      public static void main(String[] args) {
        String name = "";
        String number1 = "";
        int number = 0;
        DSCC[] array = new DSCC[10];
        Main main1 = new Main();
        DSCC d = new DSCC();
         main1.getStudenInfo(number1, name, number);
         while(number != 999){
            main1.putInArray(array, name, number);
            main1.printList();
            main1.getStudenInfo(number1, name, number);
    public class DSCC {
        String studentname;
        String number1;
        int studentnumber;
        public DSCC() {
    }

    There are a couple things i don't get about the code here but let me point out some thing that definately don't work.
    The function getStudentInfo(...) does not change the value of its parameters Number1, Name and Number. You will need to redesign this method to get the entered values. I suggest breaking it up into three functions that return the value that the JOptionPane, like :
    public String getStudentName(){
         return JOptionPane.showInputDialog("Enter Student Name :");
    }And then replace the calls to getStudenInfo() with the three calls.
    Also the array you make is not populated, which is probably the reason for the for the NPE. For example,
    DSCC[] array = new DSCC[10];
    //here come an NullPointerException
    array[0].studentName = "Joe";
    //can't do this... array[0] == null,  studentName does not exist!This happens in your code, though it is split up into different methods. If you trace through you will see that when you call the method putInArray(...) , the array's values are still null. For a fully intialized array, it should be:
    DSCC[] array = new DSCC[10];
    for(int i = 0; i < 10; i++) {
         array[0] = new DSCC();
    array[0].studentName = "Joe";So at some point you need to initialize the values of the array.
    Hope that helps....

  • Accessing a user array elements in Captivate 6

    Hi guys I have a piece of code that's not working I was hoping someone had any clue as to why, I've wasted too many hours trying to figure this out.  Here's the code, explanation below.
    var objCP = document.Captivate;
    objCP.cpEISetValue("m_VarHandle.questionList", new Array(7));
    objCP.cpEISetValue("m_VarHandle.questionList[0]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[1]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[2]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[3]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[4]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[5]", 2);
    var cat1Len = 0;
    var cat2Len = 0;
    for (var i=0;i<objCP.cpEIGetValue("m_VarHandle.questionList.length");i++){
    var value = objCP.cpEIGetValue("m_VarHandle.questionList[i]");
    if (value == 1)
       {cat1Len++;}
    if (value) == 2)
       {cat2Len++;}
    alert(i);
    alert(objCP.cpEIGetValue("m_VarHandle.questionList[2]"));
    alert(value);
    I'm attempting to create a list using a captivate variable I've created called "questionList".
    I fill questionList with data and and then use that data to count, in this instance with cat1Len and cat2Len.
    After that I attempt to verify that the data is being returned correctly with a series of alerts.
    Here's the problem:
    alert(i) correctly reports the number my incrementer should be at.
    alert(objCP.cpEIGetValue("m_VarHandle.questionList[2]")) correctly reports the data in cell [2] of questionList
    but...
    alert(value) reports undefined.  How can this be? I know that I can access array elements from inside this loop and I know that I my incrementer is at the correct location so what's the deal?
    Thanks for any help!

    should be:
    var objCP = document.Captivate;
    objCP.cpEISetValue("m_VarHandle.questionList", new Array(7));
    objCP.cpEISetValue("m_VarHandle.questionList[0]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[1]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[2]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[3]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[4]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[5]", 2);
    var cat1Len = 0;
    var cat2Len = 0;
    for (var i=0;i<objCP.cpEIGetValue("m_VarHandle.questionList.length");i++){
    var value = objCP.cpEIGetValue("m_VarHandle.questionList["+i+"]");
    if (value == 1)
       {cat1Len++;}
    if (value) == 2)
       {cat2Len++;}
    alert(i);
    alert(objCP.cpEIGetValue("m_VarHandle.questionList[2]"));
    alert(value);
    i is only defined local to the javascript eval, not a global variable.  You have to pass the value, not the name of the index...
    (I just realized that this question was from 2012, but maybe it might still benefit someone...  I saw it while I was looking for something else)

  • Retrieve captivate array elements in Captivate 6

    Hi guys I have a piece of code that's not working I was hoping someone had any clue as to why, I've wasted too many hours trying to figure this out.  Here's the code, explanation below.
    var objCP = document.Captivate;
    objCP.cpEISetValue("m_VarHandle.questionList", new Array(7));
    objCP.cpEISetValue("m_VarHandle.questionList[0]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[1]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[2]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[3]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[4]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[5]", 2);
    var cat1Len = 0;
    var cat2Len = 0;
    for (var i=0;i<objCP.cpEIGetValue("m_VarHandle.questionList.length");i++){
    var value = objCP.cpEIGetValue("m_VarHandle.questionList[i]");
    if (value == 1)
       {cat1Len++;}
    if (value) == 2)
       {cat2Len++;}
    alert(i);
    alert(objCP.cpEIGetValue("m_VarHandle.questionList[2]"));
    alert(value);
    I'm attempting to create a list using a captivate variable I've created called "questionList".
    I fill questionList with data and and then use that data to count, in this instance with cat1Len and cat2Len.
    After that I attempt to verify that the data is being returned correctly with a series of alerts.
    Here's the problem:
    alert(i) correctly reports the number my incrementer should be at.
    alert(objCP.cpEIGetValue("m_VarHandle.questionList[2]")) correctly reports the data in cell [2] of questionList
    but...
    alert(value) reports undefined.  How can this be? I know that I can access array elements from inside this loop and I know that I my incrementer is at the correct location so what's the deal?
    Thanks for any help!

    should be:
    var objCP = document.Captivate;
    objCP.cpEISetValue("m_VarHandle.questionList", new Array(7));
    objCP.cpEISetValue("m_VarHandle.questionList[0]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[1]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[2]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[3]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[4]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[5]", 2);
    var cat1Len = 0;
    var cat2Len = 0;
    for (var i=0;i<objCP.cpEIGetValue("m_VarHandle.questionList.length");i++){
    var value = objCP.cpEIGetValue("m_VarHandle.questionList["+i+"]");
    if (value == 1)
       {cat1Len++;}
    if (value) == 2)
       {cat2Len++;}
    alert(i);
    alert(objCP.cpEIGetValue("m_VarHandle.questionList[2]"));
    alert(value);
    i is only defined local to the javascript eval, not a global variable.  You have to pass the value, not the name of the index...
    (I just realized that this question was from 2012, but maybe it might still benefit someone...  I saw it while I was looking for something else)

  • Need help with an array

    I'm working on creating an array that is basically a deck of cards, this is the problem.
    I'm getting this error:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
      void main()
        final int ARRAY_SIZE = 52;
        String[] deck = new String[ARRAY_SIZE];
        String[] cardValue = new String[]{"A","2","3","4","5","6","7","8","9","T","J","Q","K"};
        String[] cardSuit = new String[]{"C","H","D","S"};
        for (int count = 0; count < ARRAY_SIZE; count++)
          deck[count]= cardValue[count] + cardSuit[count];
        }I Know that this is because cardSuit is reaching the end of the array, but how do I keep this from happening and make it start from the beginning until i reach the end of the cardValue array?

    By the way thanks for the help guys, I'm in a pinch for this assignment and I appreciate all of the help.
      void main()
        final int ARRAY_SIZE = 52;
        String[] deck = new String[ARRAY_SIZE];
        String[] cardValue = new String[]{"A","2","3","4","5","6","7","8","9","T","J","Q","K"};
        String[] cardSuit = new String[]{"C","H","D","S"};
        for (int count = 0; count < ARRAY_SIZE; count++)
          deck[count]= cardValue[count % 13] + cardSuit[count % 4];
          showCards(deck);
      void showCards(String [] list)
        String cards = ("card");
        for (int count = 0; count < list.length; count++)
          print (cards);
      This is what I'm talking about. I need to be able to call the showCards method and have it display whatever cards are currently in the players hand regardless of how many cards there are. I believe that I'm right when I used the void declaration because I don't want it the method to return anything to itself.
    Right now with the code as is, i get "card" typed out 52 times.
    First how do I go about having it print out the complete deck and the order that they are in?
    Is there a way to create the deck in pre-sorted like I have below?
    This was the assignment:
    Write a ConsoleProgram to create a deck of playing cards, shuffle them, and deal out 5 cards to the player. To do this:
    � You will need an array of 52 cards. In the basic version of this program, each card is a string in the form �XY�, where X is the rank (A, 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, A) and Y is a letter designating the suite (C, H, D, S).
    � You will need to shuffle the cards by swapping the positions of two randomly selected cards in the array. For this, you should write and use three methods:
    o randRange � a method which takes 2 parameters: a minimum integer and a maximum integer. It creates a random integer in this range and returns it.
    o swap � a method which takes 3 parameters: an array of cards and two subscripts. It swaps the array elements with the given subscripts and returns nothing in its name.
    o shuffle � a method which takes 2 parameters: an array of cards and a number of times to swap cards. It shuffles by swapping two randomly selected cards the desired number of times (a possibly different pair each time). It returns nothing in its name (so it is a void method).
    � You will need an array of 5 cards for the player�s hand. After shuffling the deck, you will fill this array with the first 5 cards from the deck.
    � Display the unshuffled deck, then the shuffled deck, and finally the player�s hand. Indicate which is which in the output. For example, the output of one program run might look like this: Unshuffled: 2C, 3C, 4C, 5C, 6C, 7C, 8C, 9C, TC, JC, QC, KC, AC, 2D, 3D, 4D, 5D, 6D, 7D, 8D, 9D, TD, JD, QD, KD, AD, 2H, 3H, 4H, 5H, 6H, 7H, 8H, 9H, TH, JH, QH, KH, AH, 2S, 3S, 4S, 5S, 6S, 7S, 8S, 9S, TS, JS, QS, KS, AS Shuffled: 2C, QC, 3S, 9C, 9S, 6C, 6H, 3C, QH, 2H, 8C, 9H, AH, 4S, AS, TH, 6D, 3D, 2S, 8S, 5C, TC, 4C, 4D, 7C, AD, 9D, JD, 4H, 5S, KH, 7H, JS, 8D, TD, KC, 3H, 2D, KD, AC, KS, JC, 5H, JH, 8H, 5D, 7S, TS, QD, 7D, 6S, QS Your Hand: 2C, QC, 3S, 9C, 9S

  • How do I access array elements in one method from another method?

    Hi all!
    How do I access the array's elements from another method so that method 2 can have access to method 1's array elements? Thanks for any help!
    I am trying to create a simply program that will use a method to create an array and a SEPARATE method that will sort the array's elements (without using java's built in array features). I can create the program by simply having one method and sorting the array within that same method, BUT I want to sort the array from another method.
    Here's my code so far:
    public class ArraySort {
       public static void createArray(int size){
           double myArray[] = new double[size];    //create my new array
           for(int j=0; j < myArray.length; j++)
              myArray[j] = (200.0 * Math.random() + 1.0);   //fill the array with random numbers
       public static void sortArray(){
           // I WANT THIS METHOD TO ACCESS THE ARRAY ELEMENTS IN THE METHOD ABOVE, BUT DON'T KNOW
          //  HOW???? Please help!
        public static void main(String[] args) {
            createArray(4);    //call to create the array
    }Thanks again!
    - Johnny

    Thanks for the help all! I ve managed to get the program working, using java's built in array sort, but when i try to call on the array sort method from WITHIN my main method, nothing happens!
    Can somebody please tell me why I am not able to call on the sort method from within my main class???? Thanks!
    public class ArraySort {
       public void createArray(double[] arrayName, int size){
           double myArray[] = new double[size];  //create new array
           for(int j=0; j < myArray.length; j++)
              myArray[j] = (200.0 * Math.random() + 1.0);    //populate array with
           }                                                 //random Numbers
           sortArray(myArray); 
       } //Sort array(if I delete this & try to use it in Main method --> doesn't work???
       public void sortArray(double[] arrayName){
           DecimalFormat time = new DecimalFormat("0.00");
           Arrays.sort(arrayName);      //sort array using Java's built in array method
           for(int i = 0; i <arrayName.length; i++)
               System.out.println(time.format(arrayName)); //print arary elements
    public static void main(String[] args) {
    ArraySort newArray = new ArraySort(); //create a new instance
    double myArray[] = new double[0]; //create a new double array
    newArray.createArray(myArray,4); //build the array of indicated size
    //newArray.sortArray(myArray); //This will not work???? WHY?????//

  • Using a For Loop Index for Array Element Number?

    Hi.  Thanks in advance for the help.  I can't seem to find what I want to do here using the search function... probably because I don't know how to frame the question appropriately.  Ignore the title to this post cause it's probably wrong vocabulary for what I want to do.
    Here's the situation:
    I have a 2D array where the first column is the X data and each subsequent column is Y data (call it Y1...Yn).  The n-value varies from run to run (some runs have 4 columns of data, some have 20), but that is easily gathered when reading the data file.  I need to perform a number of operations on each set of data, the least of which is smoothing the data and graphing it, so I'm limiting my discussion to these 2 operations.
    What I want is a for loop structure where the indexing of the loop tracks the Y1...Yn columns, grabs each column for the iteration, performs the relevant analysis, and spits out the result, but in a stackable manner.  Thus the title; I want to use the for loop's index to mark the array element for building a new array.
    See the image attached.  A 2D array of 9 columns (X, Y1...Y8) is analyzed such that each data set, (X, Y1), (X, Y2)...(X, Y8) is bundled, graphed, run through a B-spline Fit, of which is also graphed.  I need to replace this with something that looks like the for loop structure shown.  
    I just don't know how to get those two data bundles [(X, Yi) and it's smoothed pair] out of the for loop in a stacked set from every iteration of the for loop.
    Again the title, I think I want to build a new array where i use the index of the for loop to control the entries of the new array.  But I can't see how to do that.
    Any help would be appreciated.
    Attachments:
    NeedForLoopForThis.PNG ‏30 KB

    Hello H.R. Dunham, and welcome to the forum!
    It seems that you may be looking for Auto-Indexing, a basic feature of loops in LabVIEW.  You'll need to transpose your array before wiring it into the for loop, as elements are auto-indexed by row before column, but at that point you should be able to operate on each column and output an array of n cluster elements corresponding to your input columns.  Auto-indexing tunnels look like brackets to indicate each element will be indexed automatically- this should be the default when wiring an array into a for loop or when wiring anything out of a for loop.
    As for how to build your pairs, I suggest removing the X column and creating a "starter" cluster containing your X data and placeholder Y data before entering your "Y" processing loop.  Use the bundle by name function in the for loop to insert your processed column data into the cluster and auto-index the cluster output. Flow would be something like this:
    1) Gather data
    2) Split X and Y using standard array operations
    3) Create "template" cluster with shared X data
    4) Pass template cluster and Y-column array into an auto-indexed for loop.
    5) Insert processed Y data into cluster inside loop.
    6) Auto-index cluster data out of loop.
    This tutorial is probably also a good place to get started:
    Getting Started with NI LabVIEW Module 3: Loops
    http://www.ni.com/white-paper/7528/en/
    Hope that helps!
    Regards,
    Tom L.

Maybe you are looking for

  • Content missing and problems with resync / restore functions

    Since this morning (it's early evening now), my iPod touch (3G, 64 GB, updated to iOS4 as soon as it was possible from Spain) is not working properly. It started while playing some music. It suddenly stopped without having to. I checked that the ipod

  • Https with JSSE

    Hi, I am trying to write a simple client to connect to a https server. I have a .crt and a .key files generated with openssl for the server. As I understand I need to use those somehow to make a connection to the server. Otherwise I will always get "

  • FB03:  Report that identifies which ACCTG Documents have PDF's attached?

    Hello Friends- I have an usual request.  When my accounting team executes journal entries, they attach a PDF for every transaction.  When audited, they discovered several document numbers where the user forgot to add the PDF.  Is there a report or a

  • The button "More info" (in window  "About this Mac") is inactive

    Hi! I'm really don't know what is the problem. 2 days ago it worked. MacAir (Lion 10.7.3.) Thank you in advance

  • Same old: Buzz with iMic with vocal microphone

    Yes...an old topic. I would like to do a simple voice over track in Garage Band. I bought a $30 mic at Radio Shack and then the current iMic device. I've got everything set up properly, but I get a buzz/hum in the track. This is on a PowerBook 17". I