Uploaded by sowmyasri seelam

Lab-3 Experiments

advertisement
Lab-3 (Conditional Expression and statement module)
Q.1 The count of a certain breed of bacteria was found to increase at the rate of 5% per hour.
What will be the growth of bacteria at the end of 3 hours if the count was initially 6000. ( Use
formula:- Amount = Principal(1+Rate/100)^n ).
Input :- 6000
Output:- 6945.75
Q. 2 Write a program to take 4 characters from user namely ‘A’, ‘M’, ‘S’ and ‘D’ one at a
time. Again take two integer numbers from the user and display the addition of these two
numbers if the character entered is ‘A’, display multiplication if character entered is ‘M’,
subtraction for ‘S’ and division for ‘D’. If the character entered is different from above four
characters, the message should be “You entered the wrong character”.
Q. 3 Write a program to check if the number is palindome. If the number is palindrome
display the sum of its digits otherwise display the the product of its digits.
Q. 4 A hospital in Jabalpur provides a token number (<= three digits) to each patient who
visits the hospital for the first time. Later, they utilize this token to create patient ids of the
visitors. If the visitor token number is equivalent to his generated patient ID, then he/she gets
lifetime free treatment in the hospital. Suppose a hospital provides a token T= 12 to a visitor,
then they generate the patient ID by adding the cube of each digit, e.g. 1^3 + 2^3 = 9. For
T=153, the patient ID will be 1^3 + 5^3 + 3^3= 153, which is equivalent to T. Thus, the patient
with T=153 will get free treatment. Write a program that first checks the validity of the token
number, if the token is valid (<= three digits), then provides the patient ID and shows the
eligibility for free treatment.
Q. 5 Madhya Pradesh Power Corporation Limited supplies electricity to peoples of Madhya
Pradesh. They have four ranges of charges for all the residential connections. The charges per
unit with surcharge for different ranges of consumptions are given as follows.
Unit Range
Rate per Unit
Surcharge
0-75
2.80
30
76-200
3.55
50
201-300
6.26
80
>300
8.20
100
Examples:
Input:
Input:
501
285
Output:
Output:
Electricity Bill = 3027.95
Electricity Bill = 1265.85
Download