I need help on a java program

Vigilante

Newbie
Joined
Sep 12, 2003
Messages
2,660
Reaction score
0
Hi
I'm in AP Java programming now, and we're doing a review of basic stuff. I havent taken java in over a year and i'm stumped on this program.

It's supposed to divide the smaller number by the bigger number (Big / small) and spit out the remainder, and terminate when I enter -1. I'm having trouble getting the remainder. Can anyone help me? Here's the code so far...
package divide;

import javax.swing.*;

public class divide
{
public static void main(String[] args)
{
String input, input2;
double one, two, answer;
int remainder;
input = JOptionPane.showInputDialog("Enter the first number");
input2 = JOptionPane.showInputDialog("Enter the second number");

one = Double.parseDouble(input);
two = Double.parseDouble(input2);

while(one != -1 || two != -1)
{
if(one > two)
{
answer = one / two;
JOptionPane.showMessageDialog(null, "The answer is " + answer);
System.exit(0);
}
else if(one < two)
{
answer = two / one;
JOptionPane.showMessageDialog(null, "The answer is " + answer);
System.exit(0);
}
}

}
}

I'm afraid of using mod(%) because I suck with it, but I think it's probably what I'm going to have to do. Thanks for any help. Also, it does not drop out when I enter -1, anybody know why? My bigger worry is the remainder now.
 
Back
Top