Java program to perform arithmetic and scientific operations...

Java Code:

7)


//write a java program to perform arithmetic and scientific operations...
import java.util.*; 
import java.util.Scanner;

public class prgr7
{

public static void main(String[] ar) 
{ Double a,b,sinValue,cosValue,tanValue,degrees,radians; 
Scanner in=new Scanner(System.in);  
System.out.println("ARITHMETIC OPERATIONS");
System.out.println("Enter two values for Addition");
 a=in.nextDouble();
 b=in.nextDouble();
System.out.println("Addition"+(a+b));
System.out.println("Enter two values for Subtraction");
 a=in.nextDouble();
 b=in.nextDouble();
System.out.println("Subtraction"+(a-b));
System.out.println("Enter two values for Multiplication");
 a=in.nextDouble();
 b=in.nextDouble();
System.out.println("Multiplication"+(a*b));
System.out.println("Enter two values for Division");
 a=in.nextDouble();
 b=in.nextDouble();
System.out.println("Division"+(a/b));
        System.out.println("SCIENTIFIC OPERATIONS");
        System.out.println("Enter degrees for sin");
        degrees = in.nextDouble(); 
        radians = Math.toRadians(degrees); 
        sinValue = Math.sin(radians);  
        System.out.println("sin(" + degrees + ") = " + sinValue); 
    
        System.out.println("Enter degrees for cos");
        degrees = in.nextDouble(); 
        radians = Math.toRadians(degrees); 
        cosValue = Math.cos(radians); 
        System.out.println("cos(" + degrees + ") = " + cosValue); 

        System.out.println("Enter degrees for tan");
        degrees = in.nextDouble(); 
        radians = Math.toRadians(degrees); 
        tanValue = Math.tan(radians); 
        System.out.println("tan(" + degrees + ") = " + tanValue); 

OUTPUT:

C:\Users\shri krishna\Desktop>javac prgr7.java

C:\Users\shri krishna\Desktop>java prgr7
ARITHMETIC OPERATIONS
Enter two values for Addition
2
3
Addition5.0
Enter two values for Subtraction
3
3
Subtraction0.0
Enter two values for Multiplication
3
3
Multiplication9.0
Enter two values for Division
3
3
Division1.0
SCIENTIFIC OPERATIONS
Enter degrees for sin
3
sin(3.0) = 0.052335956242943835
Enter degrees for cos
6
cos(6.0) = 0.9945218953682733
Enter degrees for tan
5
tan(5.0) = 0.087488663525924

Comments

POPULAR POSTS

POPULAR POSTS