Answers for "java how to add"

2

java sum of two numbers program intellij

import java.util.Scanner;
public class AddTwoNumbers2 {

    public static void main(String[] args) {
        
        int num1, num2, sum;
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter First Number: ");
        num1 = sc.nextInt();
        
        System.out.println("Enter Second Number: ");
        num2 = sc.nextInt();
        
        sc.close();
        sum = num1 + num2;
        System.out.println("Sum of these numbers: "+sum);
    }
}

Output:
Posted by: Guest on June-08-2020
1

how to addin java

int x = 20; // makes x = to 20, while making 20 an integer instead of a string
int y = 21; // same as x
System.out.println("Addition =" x + y);
Posted by: Guest on February-16-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language