How to add two double data type value in java and value entered by user

//How to add two double data type value in java and value entered by user

import java.util.*;
public class M
{
public static void main(String args[])
{
double a,b,c;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the value of a:");
a=sc.nextDouble();
System.out.println("Enter the value of b:");
b=sc.nextDouble();
c=a+b;
System.out.println("Sum="+c);
}
}


OUTPUT:
Enter the value of a:
205.214
Enter the value of b:
452.210
Sum=657.424

No comments:

Post a Comment