QuestionQuestion

Q1) Imagine that you own a real estate agency that has been setup in Las Cruces. Being a computer programmer yourself, you demand to have a template (class) that can retrieve basic information e.g., number of rooms, furniture, floor, air conditioning, etc., and that manages additional services you would offer e.g., shampooing carpets, repair requests, etc.; RealEstate.java is the template that was given to you. Your job is to go through RealEstate.java and do the following: -
a) Enlist all the states/global variables/instance variables of the class
b) Enlist all the behaviors or methods of the class
c) You notice that the class currently has a non-parameterized constructor and thus all states are initialized to 0, null or false by default. Your job is to introduce another constructor that is parameterized and gives you the ability to initialize the states (Hint: refer to the “Car” class in the notes supplied for week 2)
You see that there’s no information about the rent if the property is rentable. Introduce an extra state “rent” (int) and add “getRent()” and “setRent(int newRent)” methods to the class.
(Make necessary changes to RealEstate.java and submit it along with your homework, describing the steps taken by you as answers to the above questions c and d)

Q2) Now that we have a template we will use it to make a manager class (this class will have a main method). In the same directory add the manager class RealEstateManager. Once you have created this class do the following
a) Create the following entries (objects)
a. Name: XYZ, Rooms: 3, Sellable: True, Rentable: False, Furniture: Fully Furnished, Rent: 0, Floors: 2, Air Conditioning: Frigid Air, Color: White, Shampoo Required: False Repairs Needed: False
b. Name: ABC, Rooms: 2, Sellable: False, Rentable: True, Furniture: Semi Furnished, Rent: 1000, Floors: 2, Air Conditioning: Frigid Air, Color: Yellow, Shampoo Required: False, Repairs Needed: False
c. Name: PQR, Rooms: 1, Sellable: False, Rentable: True, Furniture: Semi Furnished, Rent: 700, Floors: 1, Air Conditioning: Cooler, Color: Yellow, Shampoo Required: False, Repairs Needed: False
b) Now that you have created these entries, create a method in your class that takes an object as a parameter and displays the value of all its states or global variables.
c) Finally, create two additional methods HandleShampooRequest and HandleRepairRequest, both of which takes an object as an input and sets Shampoo Required or Repairs Needed equal to true, respectively, for the given object.

Q3) Write a small Calculator console application, which takes 2 numbers (operands) and an operator (“+”,”–“, “*”, “/”, “%”) as user’s input and prints the resultant calculation on screen. You are required to write 5 methods to perform the sum, difference, product, division, and remainder of two numbers. Use if/if-else or switch statement in the main method to determine which method should be called based on user’s selection of the operator.

Enter the first number: 5 (Input)
Enter the second number: 6 (Input)
Enter the operator choice: * (Input)
The product of the 2 numbers is: 30 (Output)

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

public class Hw3_1 {

    public static void main(String[] args) {
       Scanner keyboard = new Scanner(System.in);
       String friendList = "";
       String friendName = "";
       String option = "";
       do {
            System.out.println("Enter your friend’s name");
            friendName = String.valueOf(keyboard.nextLine());

            System.out.println("Exit? Type e to exit. Otherwise, type c to continue. ");
            option = String.valueOf(keyboard.nextLine());

            // <Your code to combine the friendName to friendList goes here>
            friendList += friendName;
            if (!option.equalsIgnoreCase("e")) {
                friendList += ",";
            }...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

50% discount

Hours
Minutes
Seconds
$25.00 $12.50
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats