Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Multiplier

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Multiplier

    I don't understand what's wrong with the program. Anyone that can help me it will be greatly appreciated.


    (Write a program that uses dialog boxes to get two numbers from a user, multiplies the two numbers, and displays the result in two decimal places using another dialog box.)

    import javax.swing;
    public class MultiplierHB1
    {
    public static void main(String[] args);
    {
    	String str1;
    	String str2;
    	int a; int b; int total;
    }
    	str1 = JOptionPane.showInputDialog("Please enter a number");
    	a = Integer.parseInt(str1);
        //Taking string and converting to integer//
     
        str2 = JOptionPane.showInputDialog("Please enter second number to find the multiplier");
        //Explain to the user as clear as possible to get clarity//
     
        b = Integer.parseInt(str2);
        JOptionPane.showInputDialog(total = a * b %.2f);
        //multiplying the total numbers from the user//
     
        JOptionPane.showInputDialog("Your total is");
    	System.exiit(0);
    	}
     
    }


  2. #2
    Member DanBrown's Avatar
    Join Date
    Jan 2011
    Posts
    134
    My Mood
    Confused
    Thanks
    1
    Thanked 12 Times in 12 Posts

    Default Re: Multiplier

    public static void main(String[] args);
    remove semi colon from the end.

    String str2;
    int a; int b; int total;
    }
    remove this '}' (curly Brace)
    Thanks and Regards
    Dan Brown

    Common Java Mistakes