07-10-2012, 04:59 AM
The first thing you try to make when you learn a new computer language is a basic calculator, right? Well, I've made many calculators and similar "softwares", but I've always had a small "error".
I set up the window with three text fields, two labels, two buttons and a list. I, also, declared three integer variables; n1, n2 and res.
Right now, you're probably like "Alright.. I cannot see a problem here", well we all know that four divided by two equals two, right? But what happens when you divide four by three? You get the result of one point three. Well, on my calculator it shows only one.
My Calculator:
NOTE: Result text field is uneditable.
Windows Calculator:
I assume you will tell me "Just change integers to doubles", but I don't want that. I want it to display any decimals except zero. Example:
4 / 2 = 2(.0) | Don't display ".0"
4 / 3 = 1(.3) | Display ".3"
The help would be highly appreciated.
I set up the window with three text fields, two labels, two buttons and a list. I, also, declared three integer variables; n1, n2 and res.
Right now, you're probably like "Alright.. I cannot see a problem here", well we all know that four divided by two equals two, right? But what happens when you divide four by three? You get the result of one point three. Well, on my calculator it shows only one.
My Calculator:
NOTE: Result text field is uneditable.
Windows Calculator:
I assume you will tell me "Just change integers to doubles", but I don't want that. I want it to display any decimals except zero. Example:
4 / 2 = 2(.0) | Don't display ".0"
4 / 3 = 1(.3) | Display ".3"
The help would be highly appreciated.
Also known as Rocketalypse.
System.out.println("I prefer Java.");
System.out.println("I prefer Java.");