0% found this document useful (0 votes)
15 views1 page

Experiment No - 9

Uploaded by

kajal visrani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

Experiment No - 9

Uploaded by

kajal visrani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Experiment No: 9

//Title:-Programs on Operators, Arithmetic Promotion, Method Calling

Source Code:-
import java.util.Scanner;
public class ArithmeticOperations
{
public static double add(double a, double b)
{
return a + b;
}
public static double subtract(double a, double b)
{
return a - b;
}

public static double multiply(double a, double b)


{
return a * b;
}
public static double divide(double a, double b)
{
return a / b;
}
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the first number: ");
double num1 = sc.nextDouble();
System.out.print("Enter the second number: ");
double num2 = sc.nextDouble();
System.out.println("Addition: " + add(num1, num2));
System.out.println("Subtraction: " + subtract(num1, num2));
System.out.println("Multiplication: " + multiply(num1, num2));
System.out.println("Division: " + divide(num1, num2));
}
}

Output:-
D:\>javac ArithmeticOperations.java

D:\>java ArithmeticOperations
Enter the first number: 12
Enter the second number: 10
Addition: 22.0
Subtraction: 2.0
Multiplication: 120.0
Division: 1.2

You might also like