PROGRAM IN JAVA

Closed
stevor12 Posts 1 Registration date Tuesday May 21, 2013 Status Member Last seen May 21, 2013 - May 21, 2013 at 08:18 AM
GeorgeRattel Posts 67 Registration date Monday September 29, 2008 Status Member Last seen September 15, 2013 - Sep 12, 2013 at 03:33 AM
I WRITE A PROGRAM OF SIMPLE CALCULATOR USING JAVA AND I DONT KNOW HOW GO ABOUT IT. PLS LET SOME ONE HELP ME
Related:

2 replies

Atabong Felix Posts 2 Registration date Tuesday May 21, 2013 Status Member Last seen May 21, 2013 1
May 21, 2013 at 01:43 PM
When You write your codes for the program in using the JAVA high level programmming language you need a JAVA compiler in your computer to compile your codes in Java. if you have the C compiler you try a program I wrote below.

/* A PROGRAM TO CALCULATE TWO NUMBERS */
#include<stdio.h>
int main(void)
{
int a , b , sum;
printf("ADDITION OF TWO NUMBERS\N");
printf("enter a, a="); scanf("%d", &a);
printf("enter b, b="); scanf("%d", &b);

sum = a+b;

printf("sum=%d", sum);
return 0;

Then compile the program and run it as an executable file. I Will prepare you some notes in JAVA, Pascal and C.
end.
1
GeorgeRattel Posts 67 Registration date Monday September 29, 2008 Status Member Last seen September 15, 2013 10
Sep 12, 2013 at 03:33 AM
In java it's way more simple
import System.util.Scanner;

Scanner scan = new Scanner(System.in);
System.out.println("Kindly enter a number");
double a = (double)scan.next();
System.out.println("Kindly enter another number");
double b = (double)scan.next();
System.out.println ("enter 1, to add, 2 to sub etc...)
int x=scan.nextInt();
if (x==1)
System.out.println(a + " + " + b + " = " + x);
if (x==2)
System.out.println(a + " - " + b + " = " + x);

you can surrond that with a while function to start again after it finishes, and you can add as many variables you like...now that's a very simple calculator that doesn't uses a GUI
0