Computer Science, asked by Anonymous, 8 months ago

Hola...! Friends( ╹▽╹ )

Q. Write a program in java to add and multiply two numbers .


Please don't Spam here ❌❌​

Answers

Answered by nafeess2019
2

Using Scanner class

import java.util.*;

public class AddMultiply

{

   public static void main(String[]args)

   {

       Scanner scan = new Scanner(System.in);

       int a,b;

       System.out.print("Enter first no. :");

       a=scan.nextInt();

       System.out.print("Enter second no. :");

       b=scan.nextInt();

       int add=a+b;

       int multiply=a*b;

       System.out.println("Addition of two no. :"+add);

       System.out.println("Multiplication of two no. :"+multiply);

       scan.close();

   }

}

Without using scanner class

public class AddMultiply

{

   public static void main(int a, intb)

   {

       int add=a+b;

       int multiply=a*b;

       System.out.println("Addition of two no. :"+add);

       System.out.println("Multiplication of two no. :"+multiply);

   }

}

Mark me brainliest :)

Answered by Anonymous
4

Explanation:

Case 1 if u have to multiply two numbers

start is in Ellipse

then down arrow

read A is in parallelogram

then down arrow

read B is in parallelogram

then down arrow

multiply=A×B is in rectangle

then down arrow

print is in parallelogram

then down arrow

CASE 2 if u have to add two numbers

start is in Ellipse

then down arrow

read A is in parallelogram

then down arrow

read B is in parallelogram

then down arrow

sum=a+b is in rectangle

then down arrow

print is in parallelogram

then down arrow

Attachments:
Similar questions