EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 5, Problem 9PE
Program Plan Intro

A class “Apartment”

Program plan:

  • In a file “Apartment.java”, create a class “Apartment”,
    • Declare the necessary variables.
    • Define the constructor to set the initial values for the necessary variables.
    • Define the method “get_AptNumber()” to return the apartment number.
    • Define the method “get_Bedrooms()” to return the number of bed rooms.
    • Define the method “get_Baths()” to return the number of bath rooms.
    • Define the method “get_Rent ()” to return the rent.
  • In a file “TestApartments.java”, create a class “TestApartments”,
    • Define the method “main ()”,
      • Create “Scanner” object.
      • Call the constructor “Apartment()” that instantiates “5” objects.
      • Declare the necessary variables.
      • Prompt the user to enter the minimum number of bed rooms.
      • Get the minimum number of bed rooms.
      • Prompt the user to enter the minimum number of bath rooms.
      • Get the minimum number of bath rooms.
      • Prompt the user to enter the maximum rent ready to pay.
      • Get from the user the maximum rent ready to pay.
      • Print the string with user criteria.
      • Execute if “true”,
        • If it is true, call the method “display1()”  for apartment-1.
        • Increment the count by “1”.
      • Execute if “true”,
        • If it is true, call the method “display1()”  for apartment-2.
        • Increment the count by “1”.
      • Execute if “true”,
        • If it is true, call the method “display1()”  for apartment-3.
        • Increment the count by “1”.
      • Execute if “true”,
        • If it is true, call the method “display1()”  for apartment-4.
      • Execute if “true”,
        • If it is true, call the method “display1()”  for apartment-5.
        • Increment the count by “1”.
      • Check whether the count is “0”,
        • If it is true, print invalid message.
          • Define the method “checkAptm()”,
            • Set the Boolean value to “false”.
            • Check whether the number of available bed rooms, bath rooms, and rent is greater than or equal to the expected number of bed rooms, bath rooms, rent,
              • If it is true, set the Boolean value to “true”.
            • Return the Boolean value.
          • Define the method “display1()”,
            • Print the output.

Blurred answer
Students have asked these similar questions
Static & Not Final Field: Accessed by every object, Changing Non-Static & Final Field: Accessed by object itself, Non-Changing Static & Final: Accessed by every object, Non-Changing Non-Static & Not Final Field: Accessed by object itself, ChangingRead the following situation and decide how the variables should be defined. You have a class named HeartsPlayerA round of Hearts starts with every player having 13 cardsPlayers then choose 3 cards to “trade” with a player (1st you pass left, 2nd you pass right, 3rd you pass across, 4th you keep)Players then strategically play cards in order to have the lowest scoreAt the end of the round, points are cumulatively totaled for each player.If one player’s total is greater than 100, the game ends and the player with the lowest score wins. 1. How should the following data fields be defined (with respect to final and static)?(a) playerPosition (These have values of North, South, East, or West)(b) directionOfPassing(c) totalScore…
a - Create a FitnessTracker class that includes data fields for a fitness activity, the number of minutes spent participating, and the date. The class includes methods to get each field. In addition, create a default constructor that automatically sets the activity to running, the minutes to 0, and the date to January 1 of the current year. Save the file as FitnessTracker.java. Create an application that demonstrates each method works correctly, and save it as TestFitnessTracker.java. b - Create an additional overloaded constructor for the FitnessTracker class you created in Exercise 3a. This constructor receives parameters for each of the data fields and assigns them appropriately. Add any needed statements to the TestFitnessTracker application to ensure that the overloaded constructor works correctly, save it, and then test it. c - Modify the FitnessTracker class so that the default constructor calls the three-parameter constructor. Save the class as FitnessTracker2.java. Create an…
This is the question I am stuck on - Radio station KJAVA wants a class to keep track of recordings it plays. Create a class named Recording that contains fields to hold methods for setting and getting a Recording’s title, artist, and playing time in seconds. Write an application that instantiates five Recording objects and prompts the user for values for the data fields. Then prompt the user to enter which field the Recordings should be sorted by—(S)ong title, (A)rtist, or playing (T)ime. Perform the requested sort procedure, and display the Recording objects. This is what I have so far - public class Recording {     private String song;     private String artist;     private int playTime;     public void setSong(String title) {         this.song = title;     }     public void setArtist(String name) {         this.artist = name;     }     public void setPlayTime(int time) {         this.playTime = time;     }     public String getSong() {         return song;     }     public String…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY