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
GeorgeRattel Posts 67 Registration date Monday September 29, 2008 Status Member Last seen September 15, 2013 - Sep 12, 2013 at 03:33 AM
Related:
- Write a program to display the first ten terms of the following series 1 11 111
- How to write & in laptop - Guide
- Fnaf 1 download pc - Download - Horror
- Tentacle locker 1 - Download - Adult games
- Windows 11 tiny iso download - Download - Windows
- Fc 24 free download for pc windows 11 - Download - Sports
2 responses
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
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.
/* 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.
GeorgeRattel
Posts
67
Registration date
Monday September 29, 2008
Status
Member
Last seen
September 15, 2013
11
Sep 12, 2013 at 03:33 AM
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
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