JAVA PROGRAMMING
4.93K subscribers
233 photos
186 files
91 links
Hello! I am @imabhi3030 and welcome to the Coding channel! Here we can learn all things related to coding and improve our skills. I am always present to help you. If you need any kind of assistance, just let me know! 😊
Download Telegram
Program to add two numbers
-------------------------------------------------
Program:

import java.util.Scanner;

public class AddTwoNumbers {
public static void main(String[] args) {
// Create a Scanner object to read input from the user
Scanner scanner = new Scanner(System.in);

System.out.print("Enter the first number: ");
// Read the first number from the user
double num

#basicprograms
Program to add two numbers by accepting input from the user:
----------------------------------------------------
Program:

import java.util.Scanner;

public class AddTwoNumbers {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

// Prompt the user to enter the first number
System.out.print("Enter the first number: ");
int num1 = input.nextInt();

// Prompt the user to enter the second number
System.out.print("Enter the second number: ");
int num2 = input.nextInt();

// Add the two numbers
int sum = num1 + num2;

// Display the result
System.out.println("The sum of " + num1 + " and " + num2 + " is " + sum);
}
}

----------------------------------------------------
#basicprograms
👍1