Hello guys need help with reverse array

Need help reversing an array, i think my code is correct but it still does not work, so im thinking it might be something else i do not see.
so far the input for the array is
6, 25 , 10 , 5
and output is still the same
6 , 25 , 10 , 5
not sure what is going on.
public class Purse
    // max possible # of coins in a purse
    private static final int MAX = 10;
    private int contents[];
    private int count;      // count # of coins stored in contents[]
     * Constructor for objects of class Purse
    public Purse()
       contents = new int[MAX];
       count = 0;
     * Adds a coin to the end of a purse
     * @param  coinType     type of coin to add
    public void addCoin(int coinType)
        contents[count] = coinType;
        count = count + 1;
     * Generates a String that holds the contents of a purse
     * @return     the contents of the purse, nicely formatted
    public String toString()
        if (count == 0)
            return "()";
        StringBuffer s = new StringBuffer("(");
        int i = 0;
        for (i = 0; i < count - 1; ++i)
            s.append(contents[i] + ", "); // values neatly separated by commas
        s.append(contents[i] + ")");
        return s.toString();
     * Calculates the value of a purse
     * @return     value of the purse in cents
    public int value()
        int sum = 0; // starts sum at zero
        for( int e : contents) // sets all to e
            sum = sum + e; //finds sum of array
        return sum; //retur
     * Reverses the order of coins in a purse and returns it
    public void reverse()
       int countA = 0;
       int x = 0;
       int y = countA - 1;                                          // 5 - 1 = 4
       for (int i = contents.length - 1; i >=0 ; i--)                        // 4, 3 , 2, 1, 0
            countA++;                                             // count = 5
        while ( x < y)
            int temp = contents[x];
            contents[x] = contents [y];
            contents [y] = temp;
            y = y- 1;                                         // 4 , 3 , 2, 1 , 0
            x = x + 1 ;                                             // 0 , 1,  2  , 3 , 4
}

ok so i went ahead and followed what you said
public void reverse()
      int a = 0;
      int b = contents.length - 1;
      while (b > a)
          int temp = contents[a];
          contents[a] = contents;
contents [b] = temp;
a++;
b--;
}and its outputting { 0, 0, 0, 0}
im thinking this is because the main array is has 10 elements with only 4 in use so this is a partial array.
Example
the array is { 6, 25, 10, 5, 0, 0, 0, 0, 0, 0,}
after the swap
{0, 0 , 0 , 0, 0 , 0 , 5 , 10 , 25, 6}
i need it to be just
{ 5, 10, 25, 6}
so it is swapping the begining and end but only with zeroes the thing is i need to reverse the array without the zeroes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Hello, I need help with my macbook pro. It looks like I cannot install anything anymore. Everytime I try to install a new software, use the migration assistant or click the lock to make changes, it simply does not react.

    Hello, I need help with my macbook pro.
    It looks like I cannot install anything anymore. Everytime I try to install a new software, I simply get stuck during the installation type process. I put in my password, it does accept it, but it does not go any further.
    I tried to reset the password, put no password, repair the permissions, the disk but nothing will do. I nearly got stuck with the log in screen but finally succeeded in disabling it.
    So I thought I might try to create a new account but I cannot click the lock to make changes. It simply refuses to react.
    I am now thinking about using the migration assistant to save all my settings, data and so fourth, but again I get stuck when I have to type in my password. It accepts it but nothing happens...
    I guess it has something to do with the authorization process, but can't find anything on the internet about it... Can you help me out?
    I am running Lion 10.7.3.
    Regards,
    Nicolas.
    (I apologize if any grammatical/structural mistakes were to be found, english is not my mother-tongue. )

    You probably won't like this suggestion, but I suggest you reinstall Lion.
    First, backup your system. Next, reboot your system, press/hold the COMMAND-R keys to boot into the Recovery HD. Select 'Reinstall Mac OS X'. If you purchased Lion as an upgrade to Snow Leopard, the reinstall process will install Lion 10.7.3. If your system came preinstalled with Lion, you might still get Lion 10.7.2. Both installs are a total install of the OS. None of your apps or data will be impacted. Just the OS.

  • I need help with 2 arrays

    I need help with this portion of my program, it's supposed to loop through the array and pull out the highest inputted score, currently it's only outputting what is in studentScoreTF[0].      
    private class HighScoreButtonHandler implements ActionListener
               public void actionPerformed(ActionEvent e)
              double highScore = 0;
              int endScore = 0;
              double finalScore = 0;
              String tempHigh;
              String tempScore;
              for(int score = 0; score < studentScoreTF.length; score++)
              tempHigh = studentScoreTF[score].getText();
                    tempScore = studentScoreTF[endScore].getText();
              if(tempHigh.length() <  tempScore.length())
                   highScore++;
                   finalScore = Double.parseDouble(tempScore);
             JOptionPane.showMessageDialog(null, "Highest Class Score is: " + finalScore);This is another part of the program, it's supposed to loop through the student names array and pull out the the names of the students with the highest score, again it's only outputting what's in studentName[0].
         private class StudentsButtonHandler implements ActionListener
               public void actionPerformed(ActionEvent e)
              int a = 0;
              int b = 0;
              int c = 0;
              double fini = 0;
              String name;
              String score;
              String finale;
              String finalName = new String();
              name = studentNameTF[a].getText();
              score = studentScoreTF.getText();
              finale = studentScoreTF[c].getText();
              if(score.length() < finale.length())
                   fini++;     
                   name = finalName + finale;
         JOptionPane.showMessageDialog(null, "Student(s) with the highest score: " + name);
                   } Any help would be appreciated, this is getting frustrating and I'm starting to get a headache from it, lol.
    Edited by: SammyP on Oct 29, 2009 4:18 PM
    Edited by: SammyP on Oct 29, 2009 4:19 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Heres a working example:
    class Compare {
        public int getHighest(int[] set) {
            int high = set[0];
            for(int i = 0; i < set.length; i++) {
                if(set[i] > high) {
                    high = set;
    return high;

  • HT204406 Hello, I need help with my iTunes match

    Helo, I need help with iTunes Match.
    I signed up for iTunes match.  It did its thing and now it is supposed to have every one of my songs in the cloud.
    I checked for Ring my bell (Which I purchase from iTunes) and it is not on my iTunes on my computer anymore?
    I did match to give my 4S with limited memory and over 400 songs the ability to put all songs in the cloud, then by connecting to my computer, somehow I can tell my phone to not sync with match, the re sync and all the songs would be deleted from my phone and then I could down load any songs I wanted on my phone, thus giving me a bunch more memory.   I could not figure out how to do this? 
    Can you please help me.  Thank you.

    You probably won't like this suggestion, but I suggest you reinstall Lion.
    First, backup your system. Next, reboot your system, press/hold the COMMAND-R keys to boot into the Recovery HD. Select 'Reinstall Mac OS X'. If you purchased Lion as an upgrade to Snow Leopard, the reinstall process will install Lion 10.7.3. If your system came preinstalled with Lion, you might still get Lion 10.7.2. Both installs are a total install of the OS. None of your apps or data will be impacted. Just the OS.

  • Need Help with simple array program!

    Hi, I have just recently started how to use arrays[] in Java and I'm a bit confused and need help designing a program.
    What this program does, it reads in a range of letters specified by the user. The user then enters the letters (a, b or c) and stores these characters into an array, which the array's length is equal to the input range the user would enter at the start of the program. The program is then meant to find how many times (a,b and c) appears in the array and the Index it first appears at, then prints these results.
    Here is my Code for the program, hopefully this would make sense of what my program is suppose to do.
    import B102.*;
    class Letters
         static int GetSize()
              int size = 0;
              boolean err = true;
              while(err == true)
                   Screen.out.println("How Many Letters would you like to read in?");
                   size = Keybd.in.readInt();
                   err = Keybd.in.fail();
                   Keybd.in.clearError();
                   if(size <= 0)
                        err = true;
                        Screen.out.println("Invalid Input");
              return(size);
         static char[] ReadInput(int size)
              char input;
              char[] letter = new char[size];
              for(int start = 1; start <= size; start++)
                   System.out.println("Please enter a letter (a, b or c) ("+size+" max), enter # to stop:");
                   input = Keybd.in.readChar();
                   while((input != 'a') && (input != 'b') && (input != 'c') && (input != '#'))
                        Screen.out.println("Invalid Input");
                        System.out.println("Please enter a letter (a, b or c) ("+size+" max, enter # to stop:");
                        input = Keybd.in.readChar();
                                    while(input == '#')
                                                 start == size;
                                                 break;
                   for(int i = 0; i < letter.length; i++)
                        letter[i] = input;
              return(letter);
         static int CountA(char[] letter)
              int acount = 0;
              for(int i = 0; i < letter.length; i++)
                   if(letter[i] == 'a')
                        acount++;
              return(acount);
         static int CountB(char[] letter)
              int bcount = 0;
              for(int i = 0; i < letter.length; i++)
                   if(letter[i] == 'b')
                        bcount++;
              return(bcount);
         static int CountC(char[] letter)
              int ccount = 0;
              for(int i = 0; i < letter.length; i++)
                   if(letter[i] == 'c')
                        ccount++;
              return(ccount);
         static int SearchA(char[] letter)
              int ia;
              for(ia = 0; ia < letter.length; ia++)
                   if(letter[ia] == 'a')
                        return(ia);
              return(ia);
         static int SearchB(char[] letter)
              int ib;
              for(ib = 0; ib < letter.length; ib++)
                   if(letter[ib] == 'b')
                        return(ib);
              return(ib);
         static int SearchC(char[] letter)
              int ic;
              for(ic = 0; ic < letter.length; ic++)
                   if(letter[ic] == 'c')
                        return(ic);
              return(ic);
         static void PrintResult(char[] letter, int acount, int bcount, int ccount, int ia, int ib, int ic)
              if(ia <= 1)
                   System.out.println("There are "+acount+" a's found, first appearing at index "+ia);
              else
                   System.out.println("There are no a's found");
              if(ib <= 1)
                   System.out.println("There are "+bcount+" b's found, first appearing at index "+ib);
              else
                   System.out.println("There are no b's found");
              if(ic <= 1)
                   System.out.println("There are "+ccount+" c's found, first appearing at index "+ic);
              else
                   System.out.println("There are no c's found");
              return;
         public static void main(String args[])
              int size;
              char[] letter;
              int acount;
              int bcount;
              int ccount;
              int ia;
              int ib;
              int ic;
              size = GetSize();
              letter = ReadInput(size);
              acount = CountA(letter);
              bcount = CountB(letter);
              ccount = CountC(letter);
              ia = SearchA(letter);
              ib = SearchB(letter);
              ic = SearchC(letter);
              PrintResult(letter, acount, bcount, ccount, ia, ib, ic);
              return;
    }     Some errors i get with my program are:
    When reading in the letters to store into the array, I get the last letter I entered placed into the entire array. Also I believe my code to find the Index is incorrect.
    Example Testing: How many letters would you like to read? 3
    Enter letter (a, b or c) (# to quit): a
    Enter letter (a, b or c) (# to quit): b
    Enter letter (a, b or c) (# to quit): c
    It prints "There are no a's'" (there should be 1 a at index 0)
    "There are no b's" (there should be 1 b at index 1)
    and "There are 3 c's, first appearing at index 0" ( there should be 1 c at index 2)
    The last thing is that my code for when the user enters "#" that the input of letters would stop and the program would then continue over to the counting and searching part for the letters, my I believe is correct but I get the same problem as stated above where the program takes the character "#" and stores it into the entire array.
    Example Testing:How many letters would you like to read? 3
    Enter letter (a, b or c) (# to quit): a
    Enter letter (a, b or c) (# to quit): #
    It prints "There are no a's'" (should have been 1 a at index 0)
    "There are no b's"
    and "There are no c's"
    Can someone please help me??? or does anyone have a program simular to this they have done and would'nt mind showing me how it works?
    Thanks
    lou87.

    Without thinking too much...something like this
    for(int start = 0; start < size; start++) {
                System.out.println("Please enter a letter (a, b or c) ("+size+" max), enter # to stop:");
                input = Keybd.in.readChar();
                while((input != 'a') && (input != 'b') && (input != 'c') && (input != '#')) {
                    Screen.out.println("Invalid Input");
                    System.out.println("Please enter a letter (a, b or c) ("+size+" max, enter # to stop:");
                    input = Keybd.in.readChar();
                if(input == '#') {
                        break;
                letter[start] = input;
            }you dont even need to do start = size; coz with the break you go out of the for loop.

  • Hi guys need Help with Displaying Splash Screen?!!?

    Hi Guys.
    Sorry for the last incomplete post my mistake!
    I need help displaying a splash screen as an advertisment or something before i have my main application run.
    Here is the code i wrote (it works as if it were a seperate application)
    package MajourProject;
    import java.awt.AWTException;
    import java.awt.Dimension;
    import java.awt.Robot;
    import java.awt.Toolkit;
    import javax.swing.ImageIcon;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JProgressBar;
    import javax.swing.JScrollPane;
    import javax.swing.JWindow;
    * @author Matt
    public class SplashScreen extends JWindow
        public SplashScreen()
            int UpTime = 20000;
            Start(UpTime);
        public void Start(int UpTime)
            ImageIcon ii = new ImageIcon("src/1.jpg");
              JScrollPane jsp = new JScrollPane(new JLabel(ii));
                    JProgressBar Bar = new JProgressBar();
              getContentPane().add(jsp);
              setSize(853,303);
              centerScreen();
              setVisible(true);
                   try
                                Thread.sleep(20000);
                               dispose();
                   catch(Exception IE)
            private void centerScreen()
                    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
                    int x = (int) ((d.getWidth() - getWidth()) / 2);
              int y = (int) ((d.getHeight() - getHeight()) / 2);
              setLocation(x, (y-100));
           public static void main(String [] args)
                 new SplashScreen();
    }but i now have a problem as i already have a main application done as i wrote this seperately. I now need to combine the two together. So what i did was in my Main Application wrote:
    Splash_Screen SS = new Splash_Screen();it then runs my Splash Screen class which i re-wrote to look as such:
    package MajourProject;
    import java.awt.AWTException;
    import java.awt.Dimension;
    import java.awt.Robot;
    import java.awt.Toolkit;
    import javax.swing.ImageIcon;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JProgressBar;
    import javax.swing.JScrollPane;
    import javax.swing.JWindow;
    * @author Matt
    public class SplashScreen extends JWindow
        public SplashScreen()
            int time = 15000;
            Start(time);
        public void Start(int UpTime)
            ImageIcon ii = new ImageIcon("src/1.jpg");
              JScrollPane jsp = new JScrollPane(new JLabel(ii));
                    JProgressBar Bar = new JProgressBar();
              getContentPane().add(jsp);
              setSize(853,303);
              centerScreen();
              setVisible(true);
                   try
                                Thread.sleep(20000);
                                dispose();
                   catch(Exception IE)
            private void centerScreen()
                    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
                    int x = (int) ((d.getWidth() - getWidth()) / 2);
              int y = (int) ((d.getHeight() - getHeight()) / 2);
              setLocation(x, (y-100));
    }it obviously runs the default constructor which then runs the other methods in the class but it doesn't seem to show can anybody help me to find out whats wrong? It seems to be there just before the main application launches but only for a split second. And when i am waiting while the thread is sleeping the area i have defined the Content pane for he cursor goes to the loading icon! I don't know if this makes any sence to you but if you can help me it would be most apreciated.
    Thanks.

    SpearOne wrote:
    Hi Encephalopathic
    why would it work if i put it in it's own application surely it wouldn't be caused by this thread.sleep?? everything after it is in fact put to sleep. In its "own" application, nothing happens after it is displayed.
    if it is the problem then could you please give me some code to add quickly to test??
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JProgressBar;
    import javax.swing.JScrollPane;
    import javax.swing.JWindow;
    import javax.swing.Timer;
    public class SplashScreen extends JWindow
      private static final String IMAGE_PATH = "src/1.jpg";
      private static final int UP_TIME = 15000;
      public SplashScreen()
        Start();
      public void Start()
        ImageIcon ii = new ImageIcon(IMAGE_PATH);
        JScrollPane jsp = new JScrollPane(new JLabel(ii));
        //JProgressBar Bar = new JProgressBar();
        getContentPane().add(jsp);
        setSize(853, 303);
        centerScreen();
      private void centerScreen()
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (int) ((d.getWidth() - getWidth()) / 2);
        int y = (int) ((d.getHeight() - getHeight()) / 2);
        setLocation(x, (y - 100));
      public static void main(String[] args)
        final JFrame frame = new JFrame("Main Frame");
        frame.setPreferredSize(new Dimension(300, 200));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        final SplashScreen splash = new SplashScreen();
        splash.setVisible(true);
        Timer swingTimer = new Timer(UP_TIME, new ActionListener()
          public void actionPerformed(ActionEvent e)
            splash.dispose();
            frame.setVisible(true);
        swingTimer.setRepeats(false);
        swingTimer.start();
    }

  • Need help with an array function

    I'm using the array index function and i would like to be able to control what elements go out on it.  For example, if i wanted only the first element to go out, i don't want the second element to send out zero.  Is there any way i can control what elements leave the array index function.  I also don't understand what the index inputs do on that function either.  If anyone has any advice on the application or can modify it in any way, please help.
    Attachments:
    Array and for loop.vi ‏1190 KB

    The index inputs determine what elements are retrieved. For example of you would wire a 10 and a 20 to your two index inputs, you would bet element #10 and element #20 of your array. You can resize it to get any desired number of elements.
    If you don't wire the index inputs, you'll get the first two elements.
    If you only wire the top index input (e.g a 10), you'll get element #10 and #11.
    LabVIEW Champion . Do more with less code and in less time .

  • 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

  • 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!

  • Need help with an array, pls could somebody help8-)

    The problem I am currently having is that I want to display variable myblock down 10 times and then test it for collison,
    I am using the variable I to store the blocks, pls excuse me as I am new to this, If I manally set the variable i to lets say 1 and 2
    and then test for collison it works, but when I use I from the for loop it only detects one object from the array, I think that there is something
    probably simple missing such as an extra variable, as you can see from the code I am trying to use the ' i ' to replace for instance addChild(blockarray[1]);
    I have set it manually to display two blocks in the code below, collison detection works, but when I want to use a loop to display and test the collison
    it only picks up one of the blocks, not sure if this is because variable i is set to 0 in the for loop, any help would be greatly appreciated, this is my first post on here as I'm new to Actionscript, ty for reading8-)
    var thehero:BlueBlock = new BlueBlock;
    thehero.x=20;
    thehero.y=20;
    addChild(thehero);
    var blockarray = new Array()
    for(var i:Number=0;i<10; i++)
    // this is where I setup my blocks
    var myblock:BlueBlock = new BlueBlock;
    blockarray[i]=myblock;
    blockarray[i].x = Math.random()*500;
    blockarray[i].y = Math.random()*400;
    trace(blockarray[i]);
    blockarray.push(myblock);
    //addChild(blockarray[i]);
    addChild(blockarray[1]);
    addChild(blockarray[2]);
    // Check for keyboard events such as the arrow keys been pressed
    stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown);
    stage.addEventListener(Event.ENTER_FRAME,blockcollision);
    function myKeyDown (e:KeyboardEvent){
    if (e.keyCode == Keyboard.LEFT){
    thehero.x -=5;
    if (e.keyCode == Keyboard.RIGHT){
    thehero.x +=5;
    if (e.keyCode == Keyboard.UP){
    thehero.y -=5;
    if (e.keyCode == Keyboard.DOWN){
    thehero.y +=5;
    function blockcollision(e:Event):void{
    if (thehero.hitTestObject(blockarray[1]))
    trace("Hit");
    if (thehero.hitTestObject(blockarray[2]))
    trace("Hit");

    Thankyou very much Andrej for your quick response, it worked perfectly, I can now carry on with my code, thanks again
    Adriannax

  • TS3276 Hello I need help with my mail app

    Hello
    I have bin trying to set up an email but I keep getting my "outgoing server" password rejected. I know I am
    not putting in the wrong information by surity.
    Could someone please help me out with this issue.
    I am running OSX version 10.7.2
    Kind Regards
    Zayne

    You probably won't like this suggestion, but I suggest you reinstall Lion.
    First, backup your system. Next, reboot your system, press/hold the COMMAND-R keys to boot into the Recovery HD. Select 'Reinstall Mac OS X'. If you purchased Lion as an upgrade to Snow Leopard, the reinstall process will install Lion 10.7.3. If your system came preinstalled with Lion, you might still get Lion 10.7.2. Both installs are a total install of the OS. None of your apps or data will be impacted. Just the OS.

  • Hello, I need help with info about upgrading windows.

    Hi, after having my PC for almost a year, I'm now I'm wondering if it's possible to upgrade my windows 7 32-bit to a windows 7 64-bit?
    Here's a link to a website which has my PC and it's specs....
    http://www.tigerdirect.com/applications/SearchTools/item-details.asp?EdpNo=6288750&CatId=4928#
    If it is possible to upgrade my windows 7 32-bit to a windows 7 64-bit, then how do I do it? And what things will be required?
    Thanks.

    upgrade is the wrong word (you can't upgrade from 32 to 64)you can install 64 bit you can use the lenovo disc to just write over whats on your HDD or you can formate your HDD then install 64 bit using the lenovo media info is here http://support.lenovo.com/en_US/downloads/detail.page?DocID=HT002492 Edit: everything you need is on the disc...drivers & Apps, windows once you get it installed run system update to get system drivers up to date
    Thinkpad R61 7733-1GU
    Thinkpad X61T 7762-54U
    Thinkpad X60T 6363-4GU
    Did a member help you today? Thank them with a Kudo!
    If a post answers your question, please mark it as an "Accepted Solution"!
    Regards,
    GMAC

  • Camera guy needs help with his first build

    Hello all-
    I work in a video rental house, and I'm sick of renting out $13,000 cameras and $16,000 lens packages all the time and not having the capability to get the gear for free and make my own projects on my own time!  To that end, I'll happily trade any video camera / production knowledge for advice on this build I'm working on.
    I’ve put together this modest $3,000 build list for a Premiere CS5 / After Effects CS5 machine.  This will be my first build, so I’m somewhat new to this, and I’d like to solicit the board’s input on the following questions:
    1)      What do you think of my MOBO / CPU / RAM pairings?  I’m not really married to any of these components, and if I should swap any one of these out for overall performance increases, I’d be happy to.
    2)      How does my drive setup look?  Have I picked any clunkers?
    3)      I’d love to hear any alternate suggestions for 20inch or so monitors in the $150 range, or quality desktop speakers in the $100 range.
    DISK SETUP- $640
                System / Boot disk – 600 GB Western Digital Velociraptor / SATA 6.0 / 10,000 RPM
                Project / Media disk – (2) x 1TB Samsung Spinpoint F3R / RAID 0 / SATA 3.0 / 7,200 RPM
                Render / Scratch disk – (4) x 500GB Western Digital Caviar blue / RAID 0 / SATA 3.0 / 7,200 RPM
    (MOBO raid only- No hardware RAID card – not in my budget right now)
    GUTS- $1,137
                CPU- i7-950 Bloomfield 3.06 GHz / Noctura NH-D14 CPU cooler
                GPU- Galaxy NVDIA GTX470 1.28 GB
                RAM- 24GB (6 x 4GB) G.SKILL Ripjaw DDR3 1333 / 9-9-9-24
                MOBO – ASUS Rampage III 1366 pin X58
    CASE / POWER - $595         
                Case - Silverstone RV02B-W
                PSU – ABS MJ1100-M / 1100 Watt / Single 12v rail
                UPS – Powercom KIN- 2200AP / 2200 VA / 1320 Watts
    HUMAN I/O – $485
                Speakers- Behringer MS16
                Mouse – Kensington Expert Trackball
                Keyboard – Logitech Wireless K340
                Monitors – (2) x Acer G235HAbd 23” / 1920x1080 / 20” or larger / around $150
    Thanks for any input.
    -Leo

    Leo,
    Nice system specification! Like Harm, I don't have much to suggest - only a comment on the keyboard!
    I personally went with the Logitech K800, which is also wireless, after comparing it with the K340 in a store that had both on display. I preferred the feel of this more expensive model and am still very happy with the purchase 6 months later. The K800 also adds backlighting which I love for editing in a dimly lit room.
    Jim

  • Need help with an arrays program

    this is the task
    1.instantiate an array to hold integer test scores
    2.determine and print out the total number of scores
    3.determine whether there are any perfect scores (100) and if so print student numbers (who received these scores)
    4.print out only the scores that are greater or equal to 80
    5.calculate the percentage of students that got scores of 80 or above (and print out)
    6.calculate the average of all scores (and print out)
    heres the code that i came up with
    int [] scores = {79, 87, 94, 82, 67, 100, 98, 87, 81, 74, 91, 59, 97, 62, 78, 66, 83, 75, 88, 94, 63, 44, 100, 69, 87, 99, 76, 72};
    int total=scores.length;
    System.out.println("The total number of scores is: "+total);
    for (int i=0;i<=scores.length;i++)
    System.out.println(scores);
    step 2 is as far as i got
    i got stuck at step 3, i cant figure out how to do that
    reply plz, ty

    3.determine whether there are any perfect scores (100) and if so print student numbers (who received these scores)This question strongly suggests that the data contains information about students associated with each of the test scores. As you have illustrated it, part 3 is simply not doable. There must be more to the assignment than you have said.
    Do one thing at a time and make sure your code compiles and runs as you expect before moving on. The code you have posted looks OK for the first couple of steps, but its it's impossible to say unless you post something that's runnable.
    (A small thing - but very much appreciated - can you please post code using the "code" tags? Put {code} at the start of your code and again at the end. That way the code will be nicely formatted by the forum's astounding software.)

  • Need help with an array project please =)

    I'm having trouble figuring out where to start. My project is to create an applet that accepts 20 numbers from a text field one by one and adds them to an array. The numbers have to be between 10 and 50 or else the applet shouldn't include them in the 20 but duplicates should be included in the 20. The applet then has to display all the numbers except for duplicates. example:
    user inputs:
    10,11,12,13,14,15,16,16,16,17,18,19,20,20,20,21,23,24,25,26
    applet detects that 20 numbers have been entered and displays them exluding duplicates:
    10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26
    If the user imputs a number like 72 I need to make it alert them that the number was not in the 10-50 range and not add that number to the total 20.
    I'm not asking anyone to do this for me, I'm just asking for tips on where to get a good start.
    Thanks!

    //i haven't tryed that code, and it might not work
    // anyhow, just in case, i'll also say that this is not an applet
    public class NoDublicates {
    public static void main(String[] args) {
      if (args.length < 20) {
       System.out.println("usage:\njava NoDublicates "
         + "<and 20 space separated numbers from 10 to 50 here>");
       System.exit(1);
      byte[] nums = new byte[args.length];
      int i = 0;
      for (int j = 0; j < args.length; j++) {
       try {
        int temp = Integer.parseInt(args[j]);
        if (temp <= 50 && temp >= 10) {
         nums[i++] = temp;
       } catch (NumberFormatException nfe) {
        // very bad exception, i think i'll ignore it
      if (i != 20) {
       System.out.println("it seems that i didn't get exactly 20 "
        + "parseable numbers as arguments, let's exit now.");
       System.exit(1);
      java.util.Arrays.sort(nums);
      int old = 0;
      for (int j = 0; j < 20; j++) {
       if (nums[j] != old) {
        System.out.print(nums[j] + " ");
       old = nums[j];
    }

Maybe you are looking for

  • RFC & Excel VBA  with ECC 6.0

    I use a routine like this to post movements in R/3 (This is an example for MB1A Transaction) based on information posted on a excel spreadsheet  + VBA and seudo-code created with SM35 transaction Public Sub updateRFC_BDC() 'Set sheet specific variabl

  • [JS CS3] How to select Selection Tool

    Hello, At the end of a script I wish to return to the Selection Tool (black arrow). Now the Text tool is active because the last thing the script did was to create a text frame. I do not see any property I can use to invoke the selection tool. Thanks

  • Deleting browsing history and cookies in Safari

    I have deleted browsing history and cookies in Safari, but am not sure I was successful.

  • Can Adobe Viewer only show free issues?

    I have noticed I can only access free issues in Adobe Viewer. Is this a limitation, or only a result of us using a custom sprint20 build? We would really like having the option to access non-free issues, because we have paid content-only.

  • Can't open numbers documents, says index.xml file is missing?

    can't open numbers documents, says index.xml file is missing