Computer Science, asked by swathasingh, 3 months ago

please solve 4th number please​

Attachments:

himanshu2006vps: Can I write in java

Answers

Answered by anindyaadhikari13
5

Required Answer:-

Question:

  • Write a program in Java to enter angles in Radians and convert in degrees and vice versa.

Solution:

Here is the program.

import java.util.*;

public class AngleConversions {

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

System.out.println("1. Degree to Radians.");

System.out.println("2. Radians to Degrees.");

System.out.print("\nEnter your choice: ");

switch(sc.nextInt()) {

case 1:

System.out.print("Enter angle in degrees: ");

double a=sc.nextDouble();

a=Math.toRadians(a);

System.out.println("Angle in Radian: "+a);

break;

case 2:

System.out.print("Enter angle in radians: ");

double r=sc.nextDouble();

r=Math.toDegrees(r);

System.out.print("Angle in Degree: "+r);

break;

default: System.out.println("Invalid.");

}

sc.close();

}

}

Explanation:

  • Math.toRadians() convert degrees to radians and Math.toDegrees() convert radians to degrees. Using this functions, the problem is solved.

Output is attached.

Attachments:
Similar questions