Hinzufügen von Java mithilfe der Benutzereingabe
import java.util.Scanner; //import build in library for take input from user
public class data {
public static void main(String[] args){
Scanner scan = new Scanner(System.in); // making object for scan
System.out.println("Addition of two numbers");
System.out.println("Enter Number 1: "); // enter num1
int num1 = (int) scan.nextFloat(); //taking ur answer in float format
System.out.println("Enter Number 2: "); // same thing
int num2 = (int) scan.nextFloat(); //same thing
int result = (int) (num1 + num2); //sum 2 answer that user input before
System.out.println("Result: " + result); //printing the result
}
}
Paimon