in Education by
WAP to print the result based on the user’s choice; Choices: 1. Enter 1 to print the Square root of any number 2. Enter 2 to print the Square of any number. 3. For any other choices system should give an output as- “invalid input”. please answer fast it’s urgent Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
import java. util. Scanner; public class wap { public static void main(String[] args) { Scanner sc=new Scanner(System.in) ; System. out. print(“Enter your choice: “) ; int choice=sc.nextInt() ; switch(choice) { case 1: System. out. print(“Enter a number: “) ; double a= sc. nextDouble() ; double sqrt=Math.sqrt(a) ; System. out. println(“The square root is :”+sqrt) ; break; case 2: System. out. print(“Enter a number: “) ; double b= sc. nextDouble() ; double square=Math.pow(b, 2) ; System. out. println(“The square root is :”+square) ; break; default: System. out. println(” Invalid choice”) ; } } }

Related questions

0 votes
    Wap in Java to print a pascal triangle in simple language. Please explain the logic Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    WAP in java to input 3 numbers from user and print the largest no. among them using nested if. Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    WAP in java to input 2 numbers from user and print their difference (Always Positive). Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    Write a menu driven program to do the task according to user’s choice: S = 2 – 4 + 8 – 16 + 32 – 64 + …. Up to 15 terms Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    (d) To display the colours of rainbow as per the user’s choice. Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    Write a menu driven program to do the task according to user’s choice: S = 2 – 4 + 8 – 16 + 32 – 64 + …. Up to 15 terms. Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    In a test an examinee either guesses or copies or knows the answer to a multiple choice question with four choices. The ... (d) 29 24 Select the correct answer from above options...
asked Nov 19, 2021 in Education by JackTerrance
0 votes
    Based on the print technology there are different types of printers, select the odd one among the followings: ... its very urgent Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    Complete the sentence by choosing TWO WORDS either of which will fit the blank. The two words must both produce a ... on his bike. Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    WAP to obtain 2 numbers from the user and then display the maximum number out of these 2 numbers and also display ... . (5 Points) Select the correct answer from above options...
asked Dec 28, 2021 in Education by JackTerrance
0 votes
    wap to obtain 2 numbers from the user and then display the maximum number out of those 2 numbers and also display ... from the number?n Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    WAP in java to check whether the sum of second and third digit of a 4 digit no. , is even or odd? Select the correct answer from above options...
asked Dec 23, 2021 in Education by JackTerrance
0 votes
    WAP to display all the information of student (like name, class, roll no) in qbasic Select the correct answer from above options...
asked Dec 15, 2021 in Education by JackTerrance
0 votes
    In which model Machine generates mapping Function AlgorithmRequired to answer. Single choice. (1 Point) Select the correct answer from above options...
asked Dec 27, 2021 in Education by JackTerrance
0 votes
    In which model Machine generates mapping Function AlgorithmRequired to answer. Single choice. (1 Point) Select the correct answer from above options...
asked Dec 26, 2021 in Education by JackTerrance
...