Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help with basic J Option Pane

Name: Kim Jay 2013-11-28 19:18

Hi, I made a very basic program that asks for 3 products and their price; stores them in an array; then displays them.

This is the code:

import javax.swing.JOptionPane;
class fourchan{
    public static void main(String args[]){
        String [] product = new String [3];
        double [] price = new double [3];
        int count = 0;

        for(count=0;count<3;count++){
            product[count]=(JOptionPane.showInputDialog("Please enter the name of product " +(count+1) +":"));
            price[count]=(Double.parseDouble(JOptionPane.showInputDialog("Please enter a price for product " +(count+1) +":")));
        }

        JOptionPane.showMessageDialog(null, "Number \t Product \t Price");
       
        for(count=0;count<3;count++){
            JOptionPane.showMessageDialog(null, (count+1) +"\t" +product[count] +"\t" +price[count] +"\n");
        }
       
        JOptionPane.showMessageDialog(null, "Total = " +(price[0]+price[1]+price[2]));
    }
}

The problem I'm experiencing is that I do not how to to print the output on the same pop-up window as the template ( JOptionPane.showMessageDialog(null, "Number \t Product \t Price"); ).

Can anyone show me how to this?

Thanks,
Kim

P.s. This is my first time using 4chan and my Java skills are amateur at best so please be patient with me ^^

Name: Kim Jay 2013-11-28 22:16

I suck dicks 24/7.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List