Computer Science, asked by Rushikrsingh, 6 months ago

From java book class 8 solve it​

Attachments:

Answers

Answered by anindyaadhikari13
1

Question:-

Write a program in Java to enter two double data type numbers and find the sum and difference.

Program:-

import java.util.";

class Number

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

double a, b, s;

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

a=sc.nextDouble();

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

b=sc.nextDouble();

s=a+b;

System.out.println("Sum: "+s);

s=a-b;

System.out.println("Difference: "+s);

}

}

Similar questions