1,076,394 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Posts by ccsj2206

I havente declared the Jframe becasue i am only using a console in this example, just trying to get a visual example...and yesi have been to that link and used it quite often thanks

ccsj2206
Newbie Poster
2 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

I need help making this to display the results into a Jframe GUI instead of a console im failry new to java so please help me thanks, here is the code ive used:

import java.util.ArrayList;

public class ThreeArrayLists {

    public static void main(String[] args) {
        ArrayList priceList = new ArrayList();
        ArrayList quantityList = new ArrayList();
        ArrayList amountList = new ArrayList();
        //PRICE lIST
        priceList.add(new Double(10.62));
        priceList.add(new Double(14.89));
        priceList.add(new Double(13.21));
        priceList.add(new Double(16.55));
        priceList.add(new Double(18.62));
        priceList.add(new Double(9.47));
        priceList.add(new Double(6.58));
        priceList.add(new Double(18.32));
        priceList.add(new Double(12.15));
        priceList.add(new Double(3.98));
        //QUANTITY LIST   
        quantityList.add(new Double(4.0));
        quantityList.add(new Double(8.5));
        quantityList.add(new Double(6.0));
        quantityList.add(new Double(7.35));
        quantityList.add(new Double(9.0));

        quantityList.add(new Double(15.3));
        quantityList.add(new Double(3));
        quantityList.add(new Double(5.4));
        quantityList.add(new Double(2.9));
        quantityList.add(new Double(4.8));

        extend(amountList, quantityList, priceList);
        displayList(quantityList, priceList, amountList);


    }

    private static void displayList(ArrayList quantityList, ArrayList priceList, ArrayList amountList)  {

        for (int i = 0; i < 10; i++) {

            System.out.format("%d)  %.2f * %.2f = %.2f \n",i+1, Double.valueOf(priceList.get(i).toString()), Double.valueOf(quantityList.get(i).toString()), Double.valueOf(amountList.get(i).toString()));
        }
    }

    private static void extend(ArrayList amountList, ArrayList quantityList, ArrayList priceList) {

        for (int i = 0; i < 10; i++) {
            amountList.add((Double.valueOf(priceList.get(i).toString())) * (Double.valueOf(quantityList.get(i).toString())));

        }

    }
}
ccsj2206
Newbie Poster
2 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
 
© 2013 DaniWeb® LLC
Page rendered in 0.0480 seconds using 2.47MB