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

Thread: Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.

    import javax.swing.*;
    public class failornot {
    public static void main (String args[]) {
    String s1=JOptionPane.showInputDialog("NAME ? ");
    int s2=Integer.parseInt(JOptionPane.showInputDialog("H OMEWORKS POıNTS ? "));
    int s3=Integer.parseInt(JOptionPane.showInputDialog("M IDTERM POINTS ? "));
    int s4=Integer.parseInt(JOptionPane.showInputDialog("F INAL POINTS ? "));
    double achieve=0.25*s2+0.35*s3+0.4*s4;
    String z=" DEAR "+s1;
    if(achieve < 60)
    {z+=" YOU FAILED. GAME OVER ";
    JOptionPane.showMessageDialog(null,z,JOptionPane.W ARNING_MESSAGE);}
    {z+=" CONGRATULATIONS ";
    JOptionPane.showMessageDialog(null,z,JOptionPane.P LAIN_MESSAGE);}
    }
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,607
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.

    Oh my. Do you really write your code in giant red comic sans?

    Use the highlight tags instead.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.

    i changed. sorry for it.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,607
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.

    It's okay, but you still haven't used the highlight tags.

    I'm also not sure what your question is. What does this code do? Does it compile? Does it throw an Exception? If so, what line is the problem on?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,707
    Thanks
    25
    Thanked 338 Times in 313 Posts

    Default Re: Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.

    You didn't use the highlight tags.

    Also, what is your error?

    EDIT: Oh, you have an if/else statement, with a block for the if and a block for the else, but you never use the else keyword. An if/else statement looks like this:
    if(someCondition) {
         //Do something
    }
    else { //<-- You forgot this else keyword
         //Do Something
    }
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  6. #6
    Junior Member
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.

    really thanks for the replies. i solved my problem. i'll back soon with my new problems.

  7. #7
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.

    Quote Originally Posted by ihatejava View Post
    really thanks for the replies. i solved my problem. i'll back soon with my new problems.
    Glad it is working, and good luck on your new problems. Please mark threads as solved when your questions have been answered.

Similar Threads

  1. [SOLVED] Gotten easy code by proffessor that I don't understand, do you?
    By matitorn in forum Java Theory & Questions
    Replies: 7
    Last Post: October 9th, 2012, 02:30 PM
  2. Having a hard time to solve this (probably easy for the rest of you)
    By obie in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 6th, 2012, 09:54 AM
  3. Replies: 0
    Last Post: July 2nd, 2012, 10:11 PM
  4. an easy clear java programming tutorial
    By zkil_jpf in forum The Cafe
    Replies: 2
    Last Post: April 22nd, 2010, 09:40 AM
  5. Please solve my error occured java.lang.NullPointerExceptio
    By Viruthagiri in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: March 24th, 2010, 09:29 AM