3. In this java program. Explain everyline of this code. Source Code: import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print("Enter first number: "); // ask user to enter first number int a=sc.nextInt(); System.out.print("Enter second number: "); //ask user to enter second number int b=sc.nextInt(); int u=a+b;//Logic for addition int v=a*b; //Logic for multiplication int w=a-b; //Logic for subtraction int x=a/b; //Logic for division System.out.println("Addition of "+a+" and "+b+" is ="+u); //print addtion of two number System.out.println("substraction of "+a+" and "+b+" is = "+w); //print substraction of two number System.out.println("division of "+a+" and "+b+" is = "+x); // print division of two number System.out.println("multiplication of "+a+" and "+b+" is = "+v); //print multiplication of two number } }
3. In this java
Source Code:
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("Enter first number: "); // ask user to enter first number
int a=sc.nextInt();
System.out.print("Enter second number: "); //ask user to enter second number
int b=sc.nextInt();
int u=a+b;//Logic for addition
int v=a*b; //Logic for multiplication
int w=a-b; //Logic for subtraction
int x=a/b; //Logic for division
System.out.println("Addition of "+a+" and "+b+" is ="+u); //print addtion of two number
System.out.println("substraction of "+a+" and "+b+" is = "+w); //print substraction of two number
System.out.println("division of "+a+" and "+b+" is = "+x); // print division of two number
System.out.println("multiplication of "+a+" and "+b+" is = "+v); //print multiplication of two number
}
}
Step by step
Solved in 2 steps