Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5761 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1115 |

@bt8816103042 | 739 |

@SherlockHolmes3 | 447 |

@codeantik | 441 |

@SHOAIBVIJAPURE | 430 |

@shalinibhataniya1097 | 408 |

@ShamaKhan1 | 392 |

@neverevergiveup | 381 |

@amrutakashikar2 | 355 |

@mahlawatep | 353 |

@murarry3625 | 352 |

Complete Leaderboard |

Given an integer choice denoting the choice of the user and a list containing the single value R or two values L and B depending on the choice.

If the user's choice is 1, calculate the area of the circle having the given radius(**R**).

Else if choice is 2, calculate the area of the rectangle with given length(**L**) and breadth(**B**).

**Example 1:**

**Input:**
choice = 1,
R = 5
**Output:** 78.53981633974483
**Explaination:** The choice is 1.
So we have to calculate the area of the circle.

**Example 2:**

**Input:**
choice = 2,
L = 5, B = 10
**Output:** 50
**Explaination:** Here we have to calculate the
area of the rectangle.

**Your Task:**

You do not need to read input or print anything. Your task is to complete the function **switchCase()** which takes choice and a list arr[], containing the single value R or the two values L and B, as input parameters. It should return area of the desired geomatrical figure.

**Note:** Use Math.PI for the value of pi.

**Expected Time Complexity:** O(1)

**Expected Auxiliary Space:** O(1)

**Constraints:**

1 ≤ R, L, B ≤ 100

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Java Switch Case statement

...