Results 1 to 3 of 3
Thread: Help with mathematical methods
- 07-01-2007, 08:08 PM #1
Member
- Join Date
- Jun 2007
- Posts
- 92
- Rep Power
- 0
Help with mathematical methods
I have to write a a program that gives me sum(), difference(), product(), division(), remainder().
this is what i have so far.
Thanks.Java Code:import javax.swing.JOptionPane; public class Ok { public static void main (String args[]) { int result=0; int input1 =0; int input2 =0; input1=Integer.parseInt(JOptionPane.showInputDialog(null, "Please enter the first number:")); input2=Integer.parseInt(JOptionPane.showInputDialog(null, "Please enter the second number:")); result=sum(input1, input2); JOptionPane.showMessageDialog (null, "The result is: " + result); } public static int sum (int x, int y) { return (x+y); } }
Marcus:cool:
- 07-01-2007, 08:17 PM #2
Member
- Join Date
- Jun 2007
- Posts
- 95
- Rep Power
- 0
I would do something like:
GreetingsJava Code:result=sum(input1, input2); JOptionPane.showMessageDialog (null, "The sum is: " + result); result=difference(input1, input2); JOptionPane.showMessageDialog (null, "The difference is: " + result);
Felissa:p
- 07-01-2007, 08:20 PM #3
Member
- Join Date
- Jun 2007
- Posts
- 95
- Rep Power
- 0
Similar Threads
-
Demonstration of the mathematical operators
By Java Tip in forum java.utilReplies: 0Last Post: 04-16-2008, 11:02 PM -
JSP methods example
By Java Tip in forum Java TipReplies: 0Last Post: 01-30-2008, 10:00 AM -
methods
By Zensai in forum New To JavaReplies: 10Last Post: 12-03-2007, 05:31 AM -
Methods
By Java Tip in forum Java TipReplies: 0Last Post: 12-01-2007, 08:49 PM -
Help with mathematical part in java
By lenny in forum Advanced JavaReplies: 3Last Post: 08-09-2007, 01:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks