Results 1 to 4 of 4
- 10-24-2010, 03:48 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 28
- Rep Power
- 0
modulus value keeps returning a zero value
Hi I am trying to write a basic programme that returns a modulus value but it keeps returning a value of zero no matter what values I enter,I would greatly appreciate it if someone could point out what I am doing wrong.here is the code.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package calculatemodulus;
import javax.swing.JOptionPane;
/**
*
* @author Leon
*/
public class CalculateModulus {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String numStr1,numStr2;
int num1,
num2,
modulus;
numStr1=JOptionPane.showInputDialog("Enter first number");
numStr2=JOptionPane.showInputDialog("Enter second number");
num1= Integer.parseInt(numStr1);
num2= Integer.parseInt(numStr1);
modulus= num1%num2;
JOptionPane.showMessageDialog(null,"The modulus is" +modulus);
System.exit(0);
}
}
-
Look very carefully here:
Java Code:num1 = Integer.parseInt([color="red"]numStr1[/color]); num2 = Integer.parseInt([color="red"]numStr1[/color]);
- 10-24-2010, 03:59 PM #3
Member
- Join Date
- Oct 2010
- Posts
- 28
- Rep Power
- 0
oh I'm an awful idiot,thanks for your help
-
Similar Threads
-
Returning Value from a method
By Mirix in forum New To JavaReplies: 12Last Post: 06-01-2010, 09:48 PM -
Returning An Array
By elektronika in forum New To JavaReplies: 2Last Post: 12-07-2009, 03:43 PM -
read() is not returning -1
By Mewes in forum NetworkingReplies: 0Last Post: 11-30-2009, 10:46 PM -
returning arrays
By cjohnson412 in forum New To JavaReplies: 4Last Post: 11-25-2008, 01:30 PM -
[SOLVED] Modulus/Remainder results
By antgaudi in forum New To JavaReplies: 9Last Post: 10-13-2008, 03:49 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks