Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using ONLY eclipse IDE, write a complete Java program that first creates the following two classes: class Course which contains the following attributes and member

Using ONLY eclipse IDE, write a complete Java program that first creates the following two classes:

class Course which contains the following attributes and member methods:

name ( dept. short name ( exactly 4 chars long) e.g. Comp = String ) - private

Id ( course id e.g. 2310 = integer ) - private

Appropriate constructors ( default and non default ) as well as the appropriate setter and getter methods.

A printInfo( ) method to print the attributes and their values in an organized manner.

class Teacher which contains the following attributes and member methods:

name ( teachers name = String ) - private

id ( teachers id number = integer ) - private

basicSalary ( double ) - private

extraPaymentRate ( double ) - private

coursesTaught ( group of courses taught by teacher = Array of type Course ) private

Appropriate constructors ( default and non default ) as well as the appropriate setter and getter methods.

A printInfo( ) method to print the attributes and their values in an organized manner.

Method countCourseLevel( ) which takes a level ( integer 1-4 ) as an argument and returns the number of courses of that level e.g.:

If courses taught by the teacher are: Comp1310, Encs247, Comp2310, Comp233, Comp483 and the level required is level 2 then the number of courses in that level are 3 ( sum of all courses whose id starts with 2)

Method calculateExtraPayment() which returns the value of extra payment calculated as follows (Note: rate in formula = extraPaymentRate):

Number of level 1 courses * 1 * rate + Number of level 2 courses * 2 * rate + Number of level 3 courses * 3 * rate + Number of level 4 courses * 4 * rate.

e.g. If courses taught are Comp2310, Encs337, Comp336, Comp432, Comp433 and the extraPaymentRate entered by the user is 10 then the extraPayment is:

0*1*10 + 1*2*10 + 2*3*10 + 2*4*10 = 160

You now need to create a driver class (main class) to test your program which should do the following:

Create an array of Teachers after asking the user to enter their count.

Ask the user to enter the different attributes and fill them for each teacher.

For courses, you need to ask the user to enter the number of courses first and then enter their info ( name (e.g. comp) and id (e.g. 2310)).

Your program should then display the following menu:

.Enter your choice.(1-5):

1- Print Teacher Information:

displays all attributes and their values for a teacher based on his/her id entered by the user.

2- Display teachers total salaries:

displays the name of each teacher and his/her total salary ( totalSalary = basicSalary + extraPayment ).

3- Change basicSalary for a teacher:

Allows the user to enter a teachers id number and then modify his/her basic salary.

4- Display sum of Total Salaries

Displays the sum of all total Salaries ( sum of basic salaries and extra payments) for all teachers.

5- Exit

End the program

Your program should keep working until the user selects 5 Exit.

Please note the Followings:

Your program should be well commented based on Java formal documentation.

Due Date: Tue 20/12/2022 by 10:00 pm as a reply for this message via Ritaj.

Your Program should run very similar to the following sample run:

Enter number of teachers

2

Enter teachers name, id, basic salary, and extra payment rate

Ahmad 1234 2000 10

Enter number of courses taught

3

Enter Course names and ids

Comp

2310

Encs

247

Comp

433

Enter teachers name, id, basic salary, and extra payment rate

Subha 2341 3000 20

Enter number of courses taught

2

Enter Course names and ids

Comp

132

Comp

432

Enter your choice of tasks ( 1-5 ):

Print teacher Info

Display all teachers names and total Salaries

Change basic salary for a teacher

Display sum of total salaries for all teachers

Exit

and so on

What you need to turn in:

Using one of the free UML drawing tools ( e.g. UMLet ) draw a complete UML diagram for both the Teacher and Course classes and put them both in a Word file called umls.doc in your project folder.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions