1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
prisoha [69]
4 years ago
6

Create a class named Apartment that holds an apartment number, number of bedrooms, number of baths, and rent amount. Create a co

nstructor that accepts values for each data field. Also create a get method for each field. Write an application that creates at least five Apartment objects. Then prompt a user to enter a minimum number of bedrooms required, a minimum number of baths required, and a maximum rent the user is willing to pay. Display data for all the Apartment objects that meet the user’s criteria or No apartments met your criteria if no such apartments are available.
Computers and Technology
1 answer:
Archy [21]4 years ago
7 0

Solution:

public class Apartment {

int aptNumber;

int bedrooms;

double baths;

double rent;

public Apartment(int num, int bdrms, double bths, double rent) {

aptNumber = num;

bedrooms = bdrms;

this.baths = bths;

this.rent = rent;

}

public int getAptNumber() {

return aptNumber;  

}

public int getBedrooms() {

return bedrooms;  

}  

public double getBaths() {  

return baths;  

}  

public double getRent() {  

return rent;  

}  

}  

import java.util.*;  

public class TestApartments {

public static void main(String args[]) {  

Scanner input = new Scanner(System.in);  

Apartment apts[] = new Apartment[5];

apts[0] = new Apartment(101, 2, 1, 725);

apts[1] = new Apartment(102, 2, 1.5, 775);

apts[2] = new Apartment(103, 3, 2, 870);

apts[3] = new Apartment(104, 3, 2.5, 960);  

apts[4] = new Apartment(105, 3, 3, 1100);  

int bdrms;

int baths;

double rent;

int count = 0;  

System.out.print("Enter minimum number of bedrooms needed >> ");

bdrms = input.nextInt();

System.out.print("Enter minimum number of bathrooms needed >> ");

baths = input.nextInt();  

System.out.print("Enter maximum rent willing to pay >> ");  

rent = input.nextDouble();  

System.out.println("\nApartments meeting citeria of\nat least " + bdrms + " bedrooms, at least " + baths + " baths, and " + " no more than $" + rent + " rent:");

// Write your code here

boolean isExist = false;

for(int i=0; i<apts.length; i++){

if(checkApt(apts[i], bdrms, baths, rent)){  

display(apts[i]);

isExist = true;  

}  

}  

if(!isExist){  

System.out.println("No apartments met your criteria");

}  

}  

public static boolean checkApt(Apartment apt, int bdrms, double baths, double rent) {

// Write your code here  

if(apt.getBedrooms()>=bdrms && apt.getBaths()>=baths && apt.rent<=rent)  

return true;  

return false;

}  

public static void display(Apartment apt) {

System.out.println(" Apt #" + apt.getAptNumber() + " " + apt.getBedrooms() +" bedrooms, and " + apt.getBaths() + " baths. Rent $" + apt.getRent());  

}  

}  

You might be interested in
​When converting plain text to hexadecimal for use with ProDiscover, you need to place ____________ between each character's hex
mina [271]

Answer:

Null(00) is the correct answer to the following blank.

Explanation:

Because when we changing the plain text into the hexadecimal then, we have to place null(00) to use with pro-discover in the middle of each and every hexadecimal value. We use null(00) because the null value contains 0(zero) or having no value.

So, that's why the following answer i.e., null(00) is true.

3 0
4 years ago
1. What have you understood about the do's and don'ts inside the computer lab?
fiasKO [112]

Answer:

1.do=turn off machine after you are done using it

work quietly and ask permission before using

don't =bring any food or drinks

don't change computer settings

Explanation:

plz give me as brainlist question

7 0
3 years ago
Alex recently earned his security certification and has been offered a promotion to a position that requires him to analyze and
nikitadnepr [17]

Alex recently earned his security certification and has been offered a promotion to a position that requires him to analyze and design security solutions as well as identifying users’ needs.Alex been offered

A.Security administrator

Explanation:

  • A security systems administrator handles all aspects of information security and protects the virtual data resources of a company.
  • They are responsible for desktop, mobile, and network security, and are also responsible for installing, administering and troubleshooting an organization's security solutions.
  • A security administrator is the point person for a cybersecurity team.
  • A Security Administrator installs, administers, and troubleshoots an organization's security solutions.
  • The Security Administrator will ensure the network's security, protect against unauthorized access, modification, or destruction, and troubleshoot any access problems

3 0
4 years ago
MARK AS BRANLIEST!!!!
Oxana [17]

1. The reason for a photograph being a favorite is the creativity to capture nature in one single frame.

2. Photographs present the aesthetics and ability to view the world from a new perspective. Photographs' main benefit is they associate with the good memories the last for a lifetime

5 0
2 years ago
Read 2 more answers
imagine that you are part of a team tasked with purchasing new software to manage youe company's work flow. Once you have consid
Nady [450]

Answer:

my school did this exact question and im tryna find it bruh

Explanation:

8 0
3 years ago
Other questions:
  • Write an application that displays a series of at least five student ID numbers (that you have stored in an array) and asks the
    5·1 answer
  • Please answer questions 34, 36 &amp; 37. <br><br>No explanation required. ​
    8·1 answer
  • Write a program that grades the written portion of the driver's license exam. The exam has 20 multiple choice questions (answers
    10·1 answer
  • When measuring processor speed,a megahertz is much faster than a gigahertz.true or fals
    12·1 answer
  • Computer data that is suitable for text​
    5·1 answer
  • What are the two types of commennts of java​
    12·1 answer
  • Now that you have learned the basics of acquiring relevant information through research, it's time to put your skills to work.
    7·1 answer
  • You are configuring NIC Teaming on a Windows Server system using two physical network adapters. You want to aggregate the bandwi
    10·1 answer
  • which of the following is a scenario in which an it support technician would most likely be required to implement the alternate
    14·1 answer
  • "The constructor signature is defined as the constructor __________ followed by the __________. (3 points)
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!