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 3 of 3

Thread: New to Java I need help with a simple mistake

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default New to Java I need help with a simple mistake

     
    import javax.swing.JOptionPane;
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package IntegerOperationsAssignment;
     
    /**
     *
     * @author 
     */
    public class Main {
     
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            String positiveInteger1;
            positiveInteger1 = JOptionPane.showInputDialog(null,"Please enter a positive integer","Number1");
            String positiveInteger2;
            positiveInteger2 = JOptionPane.showInputDialog(null,"Please enter a positive integer","Number2");
     
            Double positiveInteger11;
            positiveInteger11 = Double.parseDouble(positiveInteger1);
            Double positiveInteger22;
            positiveInteger22 = Double.parseDouble(positiveInteger2);
     
            Double divisionInt1;
            divisionInt1 = positiveInteger11/positiveInteger22;
            Double divisionInt1Remainder;
            divisionInt1Remainder = positiveInteger11%positiveInteger22;
            Double answerRound;
            answerRound = Math.round(divisionInt1*100)/100.00;
     
            int integerNum;
            integerNum = Integer.parseInt(positiveInteger1);
     
            Double decPartOnly;
            decPartOnly = (divisionInt1 - integerNum);
     
            Double integer1Square;
            integer1Square = Math.sqrt(positiveInteger11);
     
            Double squareRound;
            squareRound = Math.round(positiveInteger22*Math.pow(10,positiveInteger22))/Math.pow(10,positiveInteger22);
     
     
            JOptionPane.showMessageDialog(null,"NUMBER 1:                          " + positiveInteger11 + "NUMBER 2:" + positiveInteger22 + "\n" + "When" + positiveInteger11 + "is divided by" + positiveInteger22 + "the answer is" + divisionInt1 + "with a remainder of" + divisionInt1Remainder + "\n" + "When" + positiveInteger11 + "is divided by" + positiveInteger22 + "the integer part is" + divisionInt1 + "and the decimal part is" + decPartOnly + "\n" + positiveInteger11 + "divided by" + positiveInteger22 + ",rounded to 2 decimal places is" + answerRound + "\n" + "The square root of" + positiveInteger11 + ", rounded to 2 decimal places is" + answerRound + "\n" + "The square root of," + positiveInteger11 + "rounded to" + positiveInteger22 + "decimal places is" + squareRound);
     
     
        }
     
    }



    The only error the netbeans IDE it is giving me is when I type this: import javax.swing.JOptionPane;

    and this: package IntegerOperationsAssignment;

    it's underlining with red the "i" in import and it's underlining everything in the package thing.

    How do I fix this?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: New to Java I need help with a simple mistake

    The package statement should be before the import statements

  3. The Following User Says Thank You to Norm For This Useful Post:

    Reynalto (October 2nd, 2010)

  4. #3
    Member
    Join Date
    May 2010
    Posts
    36
    Thanks
    0
    Thanked 13 Times in 12 Posts

    Default Re: New to Java I need help with a simple mistake

    remember the word pic which tell you the order

    p package
    i imports
    c classes

  5. The Following User Says Thank You to j2me64 For This Useful Post:

    Reynalto (October 2nd, 2010)

Similar Threads

  1. simple java help needed
    By miss confused in forum What's Wrong With My Code?
    Replies: 6
    Last Post: June 27th, 2010, 12:29 PM
  2. Java object help(should be simple)
    By Mirak in forum Object Oriented Programming
    Replies: 5
    Last Post: May 8th, 2010, 09:43 PM
  3. Simple game in Java
    By velop in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 27th, 2010, 05:04 AM
  4. PLEASE HELP!!!! simple java program...
    By parvez07 in forum Object Oriented Programming
    Replies: 5
    Last Post: August 26th, 2009, 06:38 AM
  5. help with simple java program
    By parvez07 in forum Java Theory & Questions
    Replies: 4
    Last Post: August 25th, 2009, 07:19 AM