Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Police class with the following fields: - Officer's name - Badge number - Pay rate per hour - Total number of hours worked.

image text in transcribed

Write a Police class with the following fields: - Officer's name - Badge number - Pay rate per hour - Total number of hours worked. The class should also include the following: - Setter and getter methods (mutator and accessor methods) - A constructor that takes as arguments the officer's name and the badge number - A method that returns the officer's weekly pay (Hint: Total number of hours worked X pay rate per hour) After you create the Police class, write a separate program that demonstrates the class by creating a police object. The program should ask the user to input the data for a police officer, and then display the officer's weekly pay. Requirements 1. Use comments when appropriate. 2. Give your variables meaningful and descriptive names. Naming a variable as "x", or " y " is a bad example of variable naming. 3. Use prompts to ask the user what they have to do. Be clear. Your program should be user-friendly. (Hint: Ask a family member or friend to run your program and then ask them if your prompts make sense and/or are clear). 4. Make sure you follow the directions precisely by using the required fields, the accessor and mutator methods, a constructor, and a method in the Police class. 5. For your separate program, make sure that you create an object, ask the user for input and display the weekly pay. 6. Your project should include 2 files: a) the Police class and b) a separate program to demonstrate the Police class. Therefore, you should create a folder with the 2 files, then zip the folder and submit the zipped folder. 7. Save the Police class file as Police.java and your separate program as Test.java 8. Save the zipped folder as FirstName LastName Project2 (e.g. John_Smith_Project2)

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

More Books

Students also viewed these Databases questions