In a school there are students and teachers, but they all are persons. An every “Person” has attributes “name”, “age” and “gender”. Every person should have a method to set their details(setPersonDetails()) and to print their details(printPersonDetails()).
Calculate the unit of electricity consumed by a customer with the conditions stated below and print it a bill form.
1. For 1st 100 units @ RM 1/unit.
2. For next 100 units @ RM 2/unit.
3. For next 100 units @ RM 3/unit.
4. For next 200 units @ RM 4 /unit.
5. For next units @ RM 5/unit.
6. Tax to be added in final amount @ 10%.
7. Meter charge RM 50. extra. Construct the necessary script to solve the given problem.
Construct the necessary script to solve the given problem – Print The bill
GIVEN a M x N matrix, write a program to print the matrix after ordering all the elements of the matrix in increasing order
Input
the first line of input will contain two space-separated integers, denoting the M and N.
The next M following lines will contain N space-separated integers, denoting the elements of each list
Output
The output should be M lines containing the ordered matrix.
Note: There is a space at the end of each line
Sample input1
3 3
1 20 3
30 10 2
5 10 15
Sample output
1 2 3
5 10 11
15 20 30
Temperature conversion in
Program
Given an array of integers,update every element with largest of previous and next elements with the following exception.
a)First element - check largest of first and second.
b)Last element - check largest of last and second.
Write a program that calls a udm to calculate the area of a rectangle.
In the main method, ask user to enter two numbers. Call the calArea method to
return the area of the rectangle. calArea accepts two double and returns the area
as a double, formatted in two decimal places.
Using the random module, create a program that simulates rolling a pair of dice every time the user types “roll”. This can be done by generating numbers from 1-6 and displaying them on the screen. Keep allowing the user to type “roll” until the sum of the pair of dice rolled is 7. Once that happens, terminate the program.
Write a program which creates a class named babyRecord with four methods.
a) One method will be used to write details of a child including date of birth, name, parent names and hospital name into a file called baby_data.txt.
b) The second method will be used to read from the file baby_data.txt and store the data in a dictionary called records.
c) The third method will be used to search for a baby using baby name or parent names information in the file called baby_data.txt.
d) The last method will be used to delete records in the dictionary and file respectively.
e) Clearly show how exceptions are handled in your program in each method.
Demonstrate use of Object Oriented Programming (OOP) principles, data structures and file handling operations to carry out the following tasks:
a) Define a class named Person, with child classes named Daughter and Son who also have have derived classes named GrandSon and GrandDaughter respectively. All child classes have derived genetic features and skills from Person. Create 5 methods for getting and setting genetic features, setting and getting skills and demonstrate the concept of polymorphism.
b) Modify the answer in a) and show how the person features are captured in a file called person.txt. Also create another method to read from the file person.csv and store the data in a list called persondata. Clearly show how exceptions are handled in your program
Use the start method to find an item in the list where some of the adjacent elements are less than 72. If there are many such elements, then find the largest of them; if such an element does not exist - output the corresponding information.