0% found this document useful (0 votes)
58 views14 pages

Switch Case

Fuck

Uploaded by

Agnish Samajpati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
58 views14 pages

Switch Case

Fuck

Uploaded by

Agnish Samajpati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 14
= te tor Question 12 Write a program using switch case to find the volume of a cube, a sphere and a cuboid. For an incorrect choice, an appropriate error message should be displayed. 1. Volume of a cube = s*s*s 2. Volume of a sphere = (4/3) *m*r* r*r (m= (22/7)) 3. Volume of a cuboid = I*b*h Csi TY = eee Question 14 In order to purchase an old car, the depreciated value can be calculated as per the tariff given below: No. of years Rate of used depreciation 1 10% 2 20% 3 30% 4 50% Above 4years 60% Write a menu driven program to input showroom price and the number of years the car is used ('1' for one year old, '2' for two years old and so on Calculate the depreciated value. the original price of the car, depre value and the amount to be paid. i“ = = ” Prev Exercises Chapters Next Question 15 Using a switch case statement, write a menu driven program to convert a given temperature from Fahrenheit to Celsius and vice-versa. For an incorrect choice, an appropriate message should be displayed. Hint: ¢ = 5/9*(f£-32) and f=1.. 8%¢c+32 CYA © +S Seo ul A ig 62% = wile tre KboatTemperature.java Question 16 The volume of solids, viz. cuboid, cylinder and cone can be calculated by the formula: 1. Volume of a cuboid (v = I*b*h) 2. Volume of a cylinder (v = 1*r2*h) 3. Volume of a cone (v = (1/3)*r*r2*h) Using a switch case statement, write a program to find the volume of different solids by taking suitable variables and data types. CSya OQ @ wledgeboatcom + = We rn ‘Kumar Electronics’ has announced the following seasonal discounts on purchase of certain items. . Discount Discount Purchase on Amount Desktop Laptop Pc Up to = 0.0% 5.0% 25000 % 25,001 toz 5% 7.5% 50,000 % 50,001 toz 7.5% 10.0% 1,00,000 More than CJ 10.0% 15.0% % 1,00,000 i = = 1 Prev Exercises Chapters Next CSya ra @ wledgeboat.com = whe kayecse p to 25000 0.0% % 25,001 toz 50,000 5% = 50,001 toz 1,00,000 7.5% More than % 1,00,000 10.0% + @ 5.0% 7.5% 10.0% 15.0% Write a program to input name, amount of purchase and the type of purchase (L for Laptop and 'D' for Desktop) by a customer. Compute and print the net amount to be paid by a customer along with his name. (Net amount = Amount of purchafe® | discount) Prev Exercises Ch apters = Next CSya ree BW (-%<(e(-1o1-)-1 eco) eC) = we pe Question 6 An Electricity Board charges for electricity per month from their consumers according to the units consumed. The tariff is given below: Units Consumed Charges Up to 200 units 3.80/unit More than 200 units | . %4.40/unit and up to 300 units More than 300 units | %5.10/unit and up to 400 units More than 400 units %5.80/unit Write a program to calculate the electricity bill taking consumer's name and units consumed as inputs. Dif} the output. “« = = » Prev Exercises Chapters Next Cer = whe krpledse Question 4 A private Cab service company provides service within the city at the following rates: NON AC AC CAR CAR Upto 5 %150/- %120/- KM Beyond5 10/- %08/- KM PER KM PER KM Design a class CabService with the following description: Member variables /data members: String car_type — To store the type of car (AC or NON AC) re Exercises Chapters Next double km — To store the kilome' travelled Question 11 Write a menu driven program to calculate: 1. Area of a circle = p*r2, where p = (22/7) 2. Area of a square = side*side 3. Area of a rectangle = length*breadth Enter 'c' to calculate area of circle, 's' to calculate area of square and 'r' to actesiieas sees 2 Bree see es Sn Define a class named Customer with the following description: Instance variables /Data members: String cardName — Name of the card holder. long cardNo — Card Number. char cardType — Type of card, 'P' for Platinum, 'G' for Gold, 'S' for Silver. double purchaseAmount — The amount of purchase done on card. double cashback — The amount of cashback received. Member methods: Ciletamar(Ctring name Inna nim char 8:50em Oo GO tS Gl 4 52% x @ www.knowledgeboat.com < = Whe kryredse char cardType — Type of card, 'P' for Platinum, 'G' for Gold, 'S' for Silver. double purchaseAmount — The amount of purchase done on card. double cashback — The amount of cashback received. Member methods: Customer(String name, long num, char type, double amt) — Parameterised constructor to initialize all data members. void compute() — To compute the cashback based on purchase amount as follows: 1. For Silver ('S'), 2% of purchase Me = = m1 Prev Exercises Chapters Next Q Search... 8:50em Oe O tS Ga 852% x @ www.knowledgeboat.com < = Whe kryredse 1. For Silver ('S'), 2% of purchase amount 2. For Gold ('G'), 5% of purchase amount 3. For Platinum ('P'), 8% of purchase amount void display() — To display the details in the below format: Card Holder Name: Card Number: Purchase Amount: Cashback: Write a main method to input the card details from the user then create object of the class and call the m| r methods with the provided details. Prev Exercises Chapters Next Q Search... 8:52 oo OrF Gl 51% x @ www.knowledgeboat.com < = woe Star mall is offering discount on various types of products purchased by its customers. Following table shows different type of products and their respective code along with the discount offered. Based on the code entered, the mall is calculating the total amount after deducting the availed discount. Create a program to calculate total amount to be paid by the customer. Item Item Code Discount Laptop L 5% LCD D Th XBox x 10% Printer =P 11% Anasrnn “« = = ” Prev Exercises Chapters Next. Q Search... ® = a a = T time as per the following table: | Number of days jate | Magazines fine 5 Up to 5 days Rs.1 6 to 10 days 11 to 15 days Iterative Constructs in Java 16 to 20 days | chaptorto More than 20 days Rs. 6 Nested for loops : ‘Chapter 1 Tee a cor: of days late and type of book — 'M' for Magazine and . hope ta ee i Answer

You might also like