Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > Java Help

Reply
Thread Tools

Java Help

 
 
JDM JDM is offline
Junior Member
Join Date: Oct 2012
Posts: 1
 
      10-02-2012
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!
 
Reply With Quote
 
 
 
 
patriic48@gmail.com patriic48@gmail.com is offline
Junior Member
Join Date: Oct 2012
Location: Middle Sweden
Posts: 15
 
      10-13-2012
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hot Requirements: 1.Sr Java Developer,2.Java Developer (Java with EJB) Isaac Java 0 01-20-2011 08:41 PM
Help Help, I am intermediate in Java...need help in follow case ElementX Java 9 10-01-2008 08:02 PM
hey i am just started java,, can anyone tell me the use ,application, why java , importance of java.. manish sahu Java 3 02-14-2008 12:00 AM
[JAVA] [EVALUATION] - The Java Failure (Sorry: The Java(tm) Failure) Ilias Lazaridis Java 0 02-01-2005 10:32 AM
Job to convert Java App 1.3.1 to Java Newest of Java Michael Kintner Java 0 11-30-2003 04:42 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57