Java Reference
In-Depth Information
September 2014
Sun
Mon
Tue
Wed
Thu
Fri
Sat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
11. In the Grade Report programming example, the class Student contains
two array instance variables, coursesEnrolled and courseGrades ,tostore
the courses a student is taking and the grades in those courses. Redo the Grade
Report programming example by defining the class CourseAndGrade
that has two instance variables— courseEnrolled of type Course and
courseGrade of type char . Add appropriate constructors and methods in
this class to manipulate the instance variables. In the class Student ,usean
array instance variable coursesEnrolled of type CourseAndGrade to store
the courses a student is taking and the grade for each course.
12. In the Grade Report programming example, we created the class es Course
and Student , and in the main programwe created an array to hold student data.
Redo this programming example by defining the class StudentList with an
instance variable to hold students' data, an instance variable to store the number
of students, and an instance variable to store the tuition rate. This class contains
methods to load students' data in the array and output grade reports and the
appropriate constructors. The method main in a separate class uses the class
StudentList to create grade reports. Also, write a program to test your class.
13. In this exercise, you will design various classes and write a program to
computerize the billing system of a hospital.
a. Design the class Doctor , inherited from the class Person , defined
in Chapter 8, with an additional data member to store a doctor's
specialty. Add appropriate constructors and methods to initialize, access,
and manipulate the data members.
b. Design the class Bill with data members to store a patient's ID and
the patient's hospital charges such as pharmacy charges for medicine,
the doctor's fee, and the room charges. Add appropriate constructors
and methods to initialize, access, and manipulate the data members.
c. Design the class Patient , inherited from the class Person , defined in
Chapter 8, with additional data members to store a patient's ID, age, date of
birth, attending physician's name, the date when the patient was admitted in the
hospital, and the date when the patient was discharged from the hospital. (Use
the class Date to store the date of birth, admit date, discharge date, and the
class Doctor to store the attending physician's name.) Add appropriate
constructors andmethods to initialize, access, andmanipulate the datamembers.
Write a program to test your classes.
14. Complete Example 10-7 by writing the definitions of the eight classes. Also
write a program to test your classes.
Search WWH ::




Custom Search