This site works best with JavaScript enabled!

Example program (Java): addition of two numbers

<< previous page


In this program you can enter two numbers, which will be added.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.io.*;
import java.util.Scanner;
class Testprogram {

public static void main(String[] args) {

	long eingabe1, eingabe2, ergebnis;
	System.out.println("Please enter the two numbers, which should be added!");
	Scanner eingabe = new Scanner(System.in);
	eingabe1 = Long.valueOf(eingabe.next());
	eingabe2 = Long.valueOf(eingabe.next());
	ergebnis = eingabe1 + eingabe2;
	System.out.println(eingabe1 + " + " + eingabe2 + " = " + ergebnis);
	
}
<< previous page
Share this page
Posted on 17.10.2011 | Last modified on 20.11.2016