Results 1 to 5 of 5
Thread: Rate my app : Simple Calculator
- 03-22-2013, 11:54 AM #1
Member
- Join Date
- Mar 2013
- Posts
- 2
- Rep Power
- 0
Rate my app : Simple Calculator
Here's a simple calculator that i made with java , i am very new java programming.
Here's my code, i hope you like it.
Java Code:import java.util.Scanner; public class Main { private static Scanner input; //define a private Scanner named input public static void main ( String args[]){ input = new Scanner(System.in); double fnum;//define first number double snum;// define second number; double answer; // define answer System.out.println("Please enter a number : "); // prompt user to enter first number. fnum = input.nextDouble(); // store a number in fnum Scanner Variable System.out.println("Enter a second number :");// prompt user to enter second number. snum = input.nextDouble(); //store a number in snum Scanner Variable answer = fnum + snum; System.out.println("Plus : "+answer); answer = fnum - snum; System.out.println("Minus : "+answer); answer = fnum * snum; System.out.println("Multiply : "+answer); answer = fnum / snum; System.out.println("Divide = " + answer); } }
- 03-22-2013, 12:25 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,410
- Blog Entries
- 7
- Rep Power
- 17
Re: Rate my app : Simple Calculator
Type 0.0 for the second number and see ... then type utter nonsense for one or both of the numbers and see again ...
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-22-2013, 12:36 PM #3
Member
- Join Date
- Mar 2013
- Posts
- 2
- Rep Power
- 0
Re: Rate my app : Simple Calculator
Thanks for telling me that
I cleared out that bug
here's new one :
Java Code:import java.util.Scanner; public class Main { private static Scanner input; //define a private Scanner named input public static void main ( String args[]){ input = new Scanner(System.in); double fnum;//define first number double snum;// define second number; double answer; // define answer System.out.println("Please enter a number : "); // prompt user to enter first number. fnum = input.nextDouble(); // store a number in fnum Scanner Variable System.out.println("Enter a second number :");// prompt user to enter second number. snum = input.nextDouble(); //store a number in snum Scanner Variable if (fnum == 0.0 && snum == 0.0 ) { System.out.println("Cannot Calculate two zeros"); } else { answer = fnum + snum; System.out.println("Plus : "+answer); answer = fnum - snum; System.out.println("Minus : "+answer); answer = fnum * snum; System.out.println("Multiply : "+answer); answer = fnum / snum; System.out.println("Divide = " + answer); } } }
- 03-22-2013, 01:31 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,410
- Blog Entries
- 7
- Rep Power
- 17
Re: Rate my app : Simple Calculator
But now your calculator can't do, say, 0+0; it should refuse to divide by zero only.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-22-2013, 11:16 PM #5
Similar Threads
-
Simple calculator
By itaiyz97 in forum New To JavaReplies: 2Last Post: 09-24-2012, 05:21 PM -
Help making a very simple calculator?
By sfs in forum New To JavaReplies: 2Last Post: 01-26-2012, 03:59 AM -
Trying to make simple calculator
By Buldogg in forum New To JavaReplies: 1Last Post: 09-18-2011, 01:37 PM -
Simple Calculator
By marksey07 in forum New To JavaReplies: 12Last Post: 01-09-2011, 06:30 AM -
creating a simple calculator
By hobo in forum New To JavaReplies: 4Last Post: 11-09-2009, 03:09 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks