Computer Science, asked by ayushdev76, 1 year ago

Write a program to input two angles calculate and display whether they are complementary angles are supplementary angles if they are complementary then calculate sin value of the angle otherwise cosine if supplementary as per the user choice


Anonymous: JAVA?
ayushdev76: Sir in switch case
Anonymous: ok sure i am editing it wait

Answers

Answered by Anonymous
37
\underline{\underline{\Huge\mathfrak{Answer ;}}}

Dear ,

import java.util.*;

class supp_comp

{

public static void main()

{

Scanner S=new Scanner(System.in);

int a,b;

System.out.println("Enter the 2 angles");

a=S.nextInt();

b=S.nextInt();

int c=a+b;

if(c==180)

System.out.println("The angles are supplementary");

else if(c==90)

System.out.println("The angles are complementary");

else

System.out.println("The angles are neither supplementary nor complementary");

}

}

//use this code in blueJ

__________________________

- Regards
@dmohit432


Anonymous: print the sine and ccosine
Answered by Anonymous
40

I am doing it in JAVA :

\textsf{CODE : }

import java.util.*;

class angles

{

public static void main(String args[ ])

{

Scanner sc=new Scanner( System.in);

System.out.println("Enter the 2 angles");

int a1=sc.nextInt();

int a2=sc.nextInt();

System.out.println("Enter 1 to check complementary");

System.out.println("Enter 2 to check supplementary");

int ch=sc.nextInt();

switch(ch)

{

case 1:

if((a+b)==90)

System.out.println("Angles are complementary");

else

System.out.println("Angles are not complementary");

case 2:

if((a1+a2)==180)

{

System.out.println("Angles are supplementary");

}

else

{

System.out,println("Not supplementary ");

}

default:

System.out.println("Invalid choice");

}

}//end of main()

}//end of class

------------------------------------------------------------------------------------------

OUTPUT :

Enter 2 angles

45

45

Enter your choice

1

Print :

Angles are complimentary

OUTPUT

Enter 2 angles

80

100

Enter your choice :

2

Print :

Angles are supplementary

--------------------------------------------------------------------------------------

Note :

If you want sine and cosine , plz comment and be clear I can't understand which angles' cosine you want !

-------------------------------------------------------------------------------------------

Hope it helps :-)

______________________________________________________________________



ayushdev76: Do it in switch case
Anonymous: wait have patience please
Anonymous: now see thank you for waiting :-)
Similar questions