Java Programming, Question 2 a and b.I get this one error message in this problem. Not sure how to fix it.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Java Programming, Question 2 a and b.I get this one error message in this problem. Not sure how to fix it.
2.
16. Methods that you reference with individual objec
a. private
b. public
1.
d. no
17. Variables that are shared by every instantiation of a class are.
a. class variables
private variables
c. public variables
d. illegal
18. The keyword final used with a variable declaration indicates,
c. a symbolic constant
a. the end of the program
b. it is in a static method
d. that no more variables will be declared in the
program
19. Which of the following statements determines the square root of a number and assigns it to the variable s?
20. Which of the following expressions correctly returns an integer that represents the month of a LocalDate
s sqrt (number);
C.
b. s = Math.sqrt (number);
number = sqrt(s);
d. number = Math.sqrt(s);
object named hireDate?
a. getMonth (hireDate)
b. getMonthValue (hireDate)
c. hireDate.getMonthValue ()
d. hireDate.setMonthValue()
Programming Exercises
a. Create a class named Sandwich. Data fields include a String for the main ingredient (such as tuna), a
String for bread type (such as wheat), and a double for price (such as 4.99). Include methods to get
and set values for each of these fields. Save the class as Sandwich.java.
b. Create an application named Test Sandwich that prompts the user for data, instantiates one Sandwich
object, and displays its values. Save the application as TestSandwich.java.
a. 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 default 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 addPet Fee () that adds $10 to the
monthly rent value and calls a static method named explainPet Policy () that explains the pet fee.
Save the class as Lease.java.
alsb sdt
b. Create a class named TestLease whose main () method declares four Lease objects named leasel,
lease2, lease3, and lease4. Create a getData() method that prompts a user for values for each
field for a Lease, and return a newly constructed Lease object to the main () method, where it is
assigned to one of main () 's first three Lease objects. Do not prompt the user for values for the fourth
Lease object, but let it hold the default values. After the four Lease objects have been assigned
values, pass the leasel object to a showValues () method that displays the data. Then call the
addPet Fee () method with the leasel object, and confirm that the fee explanation statement is
displayed. Next, call the showValues () method for the leasel object again and confirm that the pet
fee has been added to the rent. Finally, call the showValues () method with each of the other three
objects. Confirm that three hold the values you supplied as input and one holds the constructor default
values. Save the application as TestLease.java.
4.
Transcribed Image Text:2. 16. Methods that you reference with individual objec a. private b. public 1. d. no 17. Variables that are shared by every instantiation of a class are. a. class variables private variables c. public variables d. illegal 18. The keyword final used with a variable declaration indicates, c. a symbolic constant a. the end of the program b. it is in a static method d. that no more variables will be declared in the program 19. Which of the following statements determines the square root of a number and assigns it to the variable s? 20. Which of the following expressions correctly returns an integer that represents the month of a LocalDate s sqrt (number); C. b. s = Math.sqrt (number); number = sqrt(s); d. number = Math.sqrt(s); object named hireDate? a. getMonth (hireDate) b. getMonthValue (hireDate) c. hireDate.getMonthValue () d. hireDate.setMonthValue() Programming Exercises a. Create a class named Sandwich. Data fields include a String for the main ingredient (such as tuna), a String for bread type (such as wheat), and a double for price (such as 4.99). Include methods to get and set values for each of these fields. Save the class as Sandwich.java. b. Create an application named Test Sandwich that prompts the user for data, instantiates one Sandwich object, and displays its values. Save the application as TestSandwich.java. a. 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 default 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 addPet Fee () that adds $10 to the monthly rent value and calls a static method named explainPet Policy () that explains the pet fee. Save the class as Lease.java. alsb sdt b. Create a class named TestLease whose main () method declares four Lease objects named leasel, lease2, lease3, and lease4. Create a getData() method that prompts a user for values for each field for a Lease, and return a newly constructed Lease object to the main () method, where it is assigned to one of main () 's first three Lease objects. Do not prompt the user for values for the fourth Lease object, but let it hold the default values. After the four Lease objects have been assigned values, pass the leasel object to a showValues () method that displays the data. Then call the addPet Fee () method with the leasel object, and confirm that the fee explanation statement is displayed. Next, call the showValues () method for the leasel object again and confirm that the pet fee has been added to the rent. Finally, call the showValues () method with each of the other three objects. Confirm that three hold the values you supplied as input and one holds the constructor default values. Save the application as TestLease.java. 4.
Desktop - Chapter 2 Exercise 7/src/Lease.java - Eclipse IDE
File Edit Source Refactor Navigate Search Project Run Window Help
0-2-2# G
AT
01
Y
3
1 import java.util.Scanner;
2
public class Lease {
4
X 5
6
7
8
9
10
11.
12
130
14
15
16
17
18
19
20
21
22
23
24
25
260
27
28
29
300
Lease.java X
4
public static void main(String[] args) {
private String name;
private int number;
private double rent;
private int term;
55°F
Clear
Y
public Lease () {
{
}
}
name="XXX";
number = 0;
rent 1000;
term= 12;
public String getName()
return name;
}
public void setName (String name) {
@Javadoc Declaration Problems X
1 error, 12 warnings, 0 others
Description
4
Resource
$
I
Path
ICDE
圓、1.666.9
T
Location
Writable
Q
Type
Smart Insert
&
28: 10:373
Transcribed Image Text:Desktop - Chapter 2 Exercise 7/src/Lease.java - Eclipse IDE File Edit Source Refactor Navigate Search Project Run Window Help 0-2-2# G AT 01 Y 3 1 import java.util.Scanner; 2 public class Lease { 4 X 5 6 7 8 9 10 11. 12 130 14 15 16 17 18 19 20 21 22 23 24 25 260 27 28 29 300 Lease.java X 4 public static void main(String[] args) { private String name; private int number; private double rent; private int term; 55°F Clear Y public Lease () { { } } name="XXX"; number = 0; rent 1000; term= 12; public String getName() return name; } public void setName (String name) { @Javadoc Declaration Problems X 1 error, 12 warnings, 0 others Description 4 Resource $ I Path ICDE 圓、1.666.9 T Location Writable Q Type Smart Insert & 28: 10:373
Expert Solution
Step 1 Solution

In the above there is error in the declaration of variables

 

 

 

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY