JS-Decision Making.

Total Number of Questions: 9
 Calculator.

Write a program to make a simple calculator using switch statement that takes operator and two numbers from user and print the result after operation.

Input Format: Write a program to make a simple calculator using switch statement that takes operator and two numbers from user and print the result after operation.

Note: Complete the Calculator function. No need to take any input.

Ans:-
const Calculator = (A, B, C) =>{
    switch(A){
        case "+":
            return (B+C);
        case "-":
            return (B-C);
        case "*":
            return (B*C);
        case "/":
            return (B/C);
    }
};

  Check whether the condition is fulfilled or not?

Write a program that takes a number and prints whether the number is divisible by 6 and 9 or not.

Note: Complete the Check_divisibility function. No need to take any input.

Ans:-
const Check_divisibility = (N) => {
    if(N%6 === 0 && N%9 === 0){
        return "Divisible by both";
    }
    else{
        return "Not Divisible by both";
    }
};

 Eligible Voter.

You are given an integer a, denoting the age of a person, and your task is, determine whether he/she is eligible to vote or not.

Note: Complete the isEligible function. No need to take any input.

Ans:-
const isEligible = (a) => {
    if(a >= 18){
        return "Eligible for Voting";
    }
    else{
        return "Not Eligible for Voting";
    }
};

 Find Relation.

PrepBuddy wants you to get familiar with various Relational operators. He provides you with two integer values x and y and asks you to find the relation between them. The relationships between integers x and y are as follows:

Note: Complete the findRelationship function. No need to take any input.

Ans:-
const findRelation = (x,y) => {
    if(x>y){
       return (x + " is greater than "+y) ;
    }
    else if(x < y){
       return (x + " is smaller than "+y) ;
    }
    else{
       return (x + " is equal to "+y) ;
    }
};

 Find Grades.

Your school has the following grading system based upon the marks(M) obtained by a student:

Your friend will enter his marks out of 50, and your task is to print his grades using a switch statement.

Note: Complete the findGrades function. No need to take any input.

Ans:-
const Last_Digit = (n) => {
    var a = n%10;
    return a;
};

 Get Value.

You are provided with a table containing some characters and their corresponding values. Your task will be to find the value from the table corresponding to an input character and return it.

|   P or p - PrepBytes |
|   Z or z - Zenith |
|   E or e - Expert Coder |
|   D or d - Data Structures |

Note: Complete the getValue function. No need to take any input.

Ans:-
const Find_the_remainder = (a,b) => {
    return b%a;
};

  Find the maximum out of three numbers.

Take three numbers and print the largest number among them if all of three are same print -1.

Note: Complete the Max_out_of_three function. No need to take any input.

Ans:-
const Max_out_of_three = (A,B,C) => {
    if(A > B && A > C) {
        return (A);
    }
    else if(B > C && B > A){
        return (B);
    }
    else if(C > A && C > B){
        return (C);
    }
    else if(C == A && C == B){
        return (-1);
    }
};

 Second Smallest.

You are given 3 distinct integers x, y and z and your task is to find and return the second smallest integer among the three provided integers.

Note: Complete the findSndSmallest function. No need to take any input.

Ans:-
const findSndSmallest = (x,y,z) => {
    if (x > y && y > z){
        return y;
    }else if (x > z && y < z){
        return z;
    }else {
        return x;
    }
};

 Check whether the triangle is Acute or Obtuse.

Write a program takes takes three angles and checks whether the triangle is acute or obtuse.

Note: Complete the Triangle_Check function. No need to take any input.

Ans:-
const Triangle_Check = (A,B,C) => {
    if (A > 90 || B > 90 || C > 90){
        return ("obtuse");
    }else if (A === 90 || B === 90 || C === 90){
        return ("right-angled")
        }   
    return ("acute");
};