//How to subtract two double data type value and values enter by user in java
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("Difference ="+c);
}
}
OUTPUT:
Enter the value of a:
45.02
Enter the value of b:
12.00
Difference =33.02
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("Difference ="+c);
}
}
OUTPUT:
Enter the value of a:
45.02
Enter the value of b:
12.00
Difference =33.02
No comments:
Post a Comment