PROGRAM IN JAVA

Closed
Report
Posts
1
Registration date
Tuesday May 21, 2013
Status
Member
Last seen
May 21, 2013
-
Posts
67
Registration date
Monday September 29, 2008
Status
Member
Last seen
September 15, 2013
-
I WRITE A PROGRAM OF SIMPLE CALCULATOR USING JAVA AND I DONT KNOW HOW GO ABOUT IT. PLS LET SOME ONE HELP ME

2 replies

Posts
2
Registration date
Tuesday May 21, 2013
Status
Member
Last seen
May 21, 2013
1
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
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2821 users have said thank you to us this month

Posts
67
Registration date
Monday September 29, 2008
Status
Member
Last seen
September 15, 2013
10
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