Java Help

Discussion in 'Software' started by JDM, Oct 2, 2012.

  1. JDM

    JDM

    Joined:
    Oct 2, 2012
    Messages:
    1
    I made a program to help me with grading papers.

    import java.util.Scanner;
    public class grade {

    /**
    * @param args
    */
    public static void main(String[] args) {
    Scanner user_in = new Scanner(System.in);
    System.out.println("Enter number of correct answers");
    int a =Integer.valueOf(user_in.nextLine());
    System.out.println("Enter number of answers");
    int b =Integer.valueOf(user_in.nextLine());
    int c = 100;
    int result;
    int result2;
    result = a/b;
    result2 = result*c;

    System.out.println("Grade="+ result2 +"%");


    }

    }
    The output is:
    Enter number of correct answers
    7
    Enter number of answers
    14
    Grade=0%

    The grade is supposed to be 50%. Every thing I try I get 0%. PLEASE HELP!
    JDM, Oct 2, 2012
    #1
    1. Advertising

  2. JDM

    patriic48@gmail.com

    Joined:
    Oct 13, 2012
    Messages:
    9
    Location:
    Middle Sweden
    Have you tried:

    result = (a/b);
    result2 = (result*c);

    The calculation is right

    import java.util.Scanner?

    Are you using swing, awt, command prompt?

    Regards / patriic48
    patriic48@gmail.com, Oct 13, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fernando Kohan

    JAVA VIRTUAL MUCHINE OR SUN JAVA

    Fernando Kohan, Nov 13, 2004, in forum: Firefox
    Replies:
    1
    Views:
    770
    Clark
    Nov 14, 2004
  2. dakine

    MS Java or Sun Java???

    dakine, Jul 20, 2004, in forum: Computer Support
    Replies:
    9
    Views:
    1,446
  3. emerald
    Replies:
    3
    Views:
    12,734
    The Modfather
    May 14, 2006
  4. chuck

    Firefox and Java - but no Java

    chuck, Mar 19, 2007, in forum: Firefox
    Replies:
    1
    Views:
    352
    Peter.Potamus.the.Purple.Hippo@gmail.com
    Mar 19, 2007
  5. -Dan-
    Replies:
    0
    Views:
    538
    -Dan-
    Aug 5, 2005
Loading...

Share This Page