Home / Questions / Q1. Write, compile, and test a class that uses the command window to display the following...
Q1. Write, compile, and test a class that uses the command window to display the following statement about comments: Program comments are nonexecuting statements you add to a file for documentation.
Also include the same statement in three different comments in the class; each comment should use one of the three different methods of including comments in a Java class. Save the class as Comments.java.
Q2. The Huntington Boys and Girls Club is conducting a fundraiser by selling chili dinners to go. The price is $7 for an adult meal and $4 for a child’s meal. Write a program that accepts the number of each type of meal ordered and display the total money collected for adult meals, children’s meals, and all meals. Save the program as ChiliToGo.java.
Q3.
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 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.
b. b. Create a class named TestLease whose main() method declares four Lease objects. Call a getData() method three times. Within the method, prompt a user for values for each field for a Lease, and return a Lease object to the main() method where it is assigned to one of main()’s Lease objects. Do not prompt the user for values for the fourth Lease object, but let it continue to hold the default values. Then, in main(), pass one of the Lease objects to a showValues() method that displays the data. Then call the addPetFee() method using the passed Lease object and confirm that the fee explanation statement is displayed. Next, call the showValues() method for the Lease 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 two hold the values you supplied as input and one holds the constructor default values. Save the application as TestLease.java.
Q4. Write an application that computes and displays the day on which you become (or became) 10,000 days old. Save the application as TenThousandDaysOld.java.
Apr 02 2020 View more View Less
The price of elasticity of demand for tvs in canada is 1.2 and the income elasticity of demand for automobiles is 3.What would the effect of a 3 percent decline in tv pri...
May 23 2018On the chart below, if the earnings per share grew from 7.61 on December 31, 2018, to 7.82 on June 30, 2019, what would be the implied earnings yield?a. 2,2%b. 4.1%c. 24.4%d. 1.8%
Apr 10 2021Do you see any flaw in arguing that organizations don't have the expertise to assess and make decisions about worthy social programs and therefore they should not get inv...
May 16 2018Otto is a biology professor at State University. The university gave Otto a sabbatical leave to study the surface of the flatworm. During the year he received a salary of...
May 03 2020suppose that a simple economy produces only the following 4 gods and services: textbooks, hamburgers, shirts and cotten. assume that all the cotten is used in the produc...
May 24 2018For each of the following options, write the letter of the correct sentence in the space provided.c. Ethical companies experience less litigation, and they are the target...
Aug 23 2021Vicki makes rag dolls. The market for rag dolls is perfectly competitive, and the going price is $8 per doll. Vicki's total costs are shown in the table below. Quantity (...
Apr 30 2020The economy of Elmendyn contains 2,000 $1 bills.A.If people hold all money as currency, what is the quantity of money.? B.If people hold all money as demand deposits and...
Jun 06 2021Imagine a kicker and a goalie who confront each other in a penalty kick that will determine the outcome of the game. The kicker can kick the ball left or right, while the...
Aug 10 2020What is the future worth (in Year 10) of $23,000 deposited at the end of Year 3 plus $28,000 deposited at the end of Year 5, and $20,000 deposited at the end of Year 8 at...
Jul 09 2021