Computer Science, asked by SƬᏗᏒᏇᏗƦƦᎥᎧƦ, 5 months ago

Solve this program
.
.
.
.
♦ No spam needed
♦Jisne spam kiya uske saare answers report kardunga.​

Attachments:

Answers

Answered by anindyaadhikari13
6

Required Answer:-

Question:

  • Write a program to input two angles. Check whether they are complementary angles or supplementary angles as per users choice.

Solution:

  • Two angles are said to be complementary angles if their sum is 90° and supplementary if their sum is 180°. We will take two angles as input, add them and check if the sum is 90° or 180° as per the condition given.

Here is the code.

import java.util.*;

public class SwitchCase {

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

double a, b;

System.out.print("Enter First Angle: ");

a=sc.nextDouble();

System.out.print("Enter Second Angle: ");

b=sc.nextDouble();

System.out.println("\n\n1. Check Complementary Angle.");

System.out.println("2. Check Supplementary Angle.");

System.out.print("Enter your choice: ");

switch(sc.nextInt())

{

case 1:

if(a+b==90)

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

else

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

break;

case 2:

if(a+b==180)

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

else

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

break;

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

}

sc.close();

}

}

Output is attached.

Attachments:
Answered by iniyavan82
2

// A simple program to find if given 4

// values can represent 4 sides of rectangle

#include <iostream>

using namespace std;

 

// Function to check if the given

// integers value make a rectangle

bool isRectangle(int a, int b, int c, int d)

{

    // Square is also a rectangle

    if (a == b == c == d)

        return true;

 

    else if (a == b && c == d)

        return true;

    else if (a == d && c == b)

        return true;

    else if (a == c && d == b)

        return true;

    else

        return false;

}

 

// Driver code

int main()

{

    int a, b, c, d;

    a = 1, b = 2, c = 3, d = 4;

    if (isRectangle(a, b, c, d))

        cout << "Yes";

    else

        cout << "No";

    return 0;

Similar questions