Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic Calculator Issue
#1
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:
[Image: scaled.php?server=687&filename=kalkulato...es=landing]
NOTE: Result text field is uneditable.


Windows Calculator:
[Image: scaled.php?server=841&filename=windowsca...es=landing]

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.");


Messages In This Thread
Basic Calculator Issue - by Vinwarez - 07-10-2012, 04:59 AM
Re: Basic Calculator Issue - by Vinwarez - 07-10-2012, 01:48 PM
Re: Basic Calculator Issue - by Vinwarez - 07-11-2012, 05:31 AM
Re: Basic Calculator Issue - by Vinwarez - 07-11-2012, 11:45 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)