Computer Science, asked by helloiamrudra2007, 1 month ago

question is write a java program for addition of four numbers using bluej method
pls help

Answers

Answered by anindyaadhikari13
4

\texttt{\textsf{\large{\underline{Solution}:}}}

Here comes the solution using Java.

import java.util.*;

public class SumOf4Numbers{

   public static void main(){

       Scanner sc=new Scanner(System.in);

       int a,b,c,d,sum;

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

       a=sc.nextInt();

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

       b=sc.nextInt();

       System.out.print("Enter third number: ");

       c=sc.nextInt();

       System.out.print("Enter fourth number: ");

       d=sc.nextInt();

       sc.close();

       sum=a+b+c+d;

       System.out.println("The sum of the numbers you entered is: "+sum);

   }

}

Logic is very simple, Accept the number > Add them up > Display the sum.

See the attachment for output.

Attachments:
Similar questions