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
Georgia [21]
2 years ago
13

Create a class named Lease with fields that hold an apartment tenant’s name, apartment number, monthly rent amount, and term of

the lease in months. Include a constructor that initializes the name to "XXX", the apartment number to 0, the rent to 1000, and the term to 12. Also include methods to get and set each of the fields. Include a nonstatic method named addPetFee() that adds $10 to the monthly rent value and calls a static method named explainPetPolicy() that explains the pet fee. Save the class as Lease.java.
Computers and Technology
1 answer:
natka813 [3]2 years ago
6 0

Answer:

package b4;

public class Lease {

// Declare the necessary instance fields

String tenant_name;

int appartment_number;

double rent_amount;

double lease_term;

// Constructor to initialize the fields to the requested values

public Lease() {

 this.tenant_name = "XXX";

 this.appartment_number = 0;

 this.rent_amount = 1000;

 this.lease_term = 12;

}

// Getter for tenant name

public String getTenant_name() {

 return tenant_name;

}

// Setter for tenant name

public void setTenant_name(String tenant_name) {

 this.tenant_name = tenant_name;

}

// Getter for appartment number

public int getAppartment_number() {

 return appartment_number;

}

// Setter for appartment number

public void setAppartment_number(int appartment_number) {

 this.appartment_number = appartment_number;

}

// Getter for rent amount per month

public double getRent_amount() {

 return rent_amount;

}

// Setter for rent amount per month

public void setRent_amount(double rent_amount) {

 this.rent_amount = rent_amount;

}

// Getter for lease term

public double getLease_term() {

 return lease_term;

}

// Setter for lease term

public void setLease_term(double lease_term) {

 this.lease_term = lease_term;

}

// Non-static method addPetFee

// It adds $10 to the current rent_amount.

// It also calls the static explainPetPolicy method

public void addPetFee() {

 this.rent_amount += 10;

 explainPetPolicy();

}

// The Static explainPetPolicy method

// Please replace the string in the println() method with the actual policy

// statement

public static void explainPetPolicy() {

 System.out.println("Explanation of the pet policy is as follows");

}

}

Explanation:

The actual source code file has been attached to this response. The code has been well commented to aid readability and understandability. Please download the file attached. It has been saved as "Lease.java"

Download java
You might be interested in
TLE 10 - ICT
Kipish [7]

Answer:

Information And Communication Technology

5 0
2 years ago
Write a program that reads in an integer value for n and then sums the integers from n to 2 * n if n is nonnegative, or from 2 *
devlian [24]

Answer:

Following are the program in c++

First code when using for loop

#include<iostream> // header file  

using namespace std; // namespace

int main() // main method

{

int n, i, sum1 = 0; // variable declaration

cout<<"Enter the number: "; // taking the value of n  

cin>>n;

if(n > 0) // check if n is nonnegative

{

for(i=n; i<=(2*n); i++)

{

sum1+= i;

}

}

else //  check if n  is negative

{

for(i=(2*n); i<=n; i++)

{

sum1+= i;

}

}

cout<<"The sum is:"<<sum1;

return 0;

Output

Enter the number: 1

The sum is:3

second code when using while loop

#include<iostream> // header file  

using namespace std; // namespace

int main() // main method

{

int n, i, sum1 = 0; // variable declaration

cout<<"Enter the number: "; // taking the value of n  

cin>>n;

if(n > 0) // check if n is nonnegative

{

int i=n;  

while(i<=(2*n))

{

sum1+= i;

i++;

}

}

else //  check if n  is negative

{

int i=n;  

while(i<=(2*n))

{

sum1+= i;

i++;

}

}

cout<<"The sum is:"<<sum1;

return 0;

}

Output

Enter the number: 1

The sum is:3

Explanation:

Here we making 2 program by using different loops but using same logic

Taking a user input in "n" variable.

if n is nonnegative then we iterate the loops  n to 2 * n and storing the sum in "sum1" variable.

Otherwise iterate a loop  2 * n to n and storing the sum in "sum1" variable.  Finally display  sum1 variable .

4 0
3 years ago
// In this exercise, you will be given a variable, it will be called: value
rjkz [21]

Answer:

import java.util.Scanner;

public class Solution {

   public static void main(String args[]) {      

     Scanner scan = new Scanner(System.in);

     System.out.println("Enter your value");

     int value = scan.nextInt();      

     greaterThanFive(value);

   }  

   public static void greaterThanFive(int userInput){

       System.out.println(userInput > 5);

   }

}

Explanation:

The first line import the Scanner which is use to enable to accept user input.

The class is defined as Solution in the next line. The main method is declared in the next line which signify the beginning of the program.

Then, a scanner object is declared called scan in the next line. Then a prompt is display to the user to input a value. The user input is stored in the variable value. The value is then passed to the method greaterThanFive.

The method greaterThanFive is declared and have just one parameter, the userInput. Inside the method, we output if the userInput is greater than 5 using the logical operator (>).

8 0
2 years ago
What component can be used for user input or display of output?
kogti [31]

Answer:

JTextField

Explanation:

JTextField is a Swing control which can be used for user input or display of output. It corresponds to a textfield and can be included with other controls such as JLabel, JButton,JList etc. on a comprehensive user interface which is application dependent. JTextField supports a read-write mode where the user can enter a value and it also supports a read-only mode which can be used to display non-editable output to the user.

4 0
3 years ago
True or false? the categories of software applications are mutually exclusive
Natali [406]
False, the categories of software applications are not mutually exclusive.
3 0
3 years ago
Read 2 more answers
Other questions:
  • Which option of the AutoCorrect tool enables you to add and delete words that do not follow abbreviation rules?
    12·1 answer
  • what version of the internet do we use as an interactive social system in which users are able to interact with senders
    7·1 answer
  • Day 1 of seeing if anyone will buy me a psn gift card (if u do u get brainliest and thanks + alot of points
    11·1 answer
  • A blogger writes that the new "U-Phone" is superior to any other on the market. Before buying the U-Phone based on this review,
    7·2 answers
  • Select the correct answer.
    7·2 answers
  • What are the 3 rules of music<br><br> ps: there is no music subject so i had to put something else
    15·2 answers
  • What is modularity?
    9·1 answer
  • Does anyone have Rblx? if so write your username
    6·1 answer
  • What are some qualities of a good game critic? What are some qualities of a bad game critic?
    7·1 answer
  • When conducting memory and recall tests, some people make an effort to normalize memories by not reporting extreme cases. this l
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!