Create a class named sandwich

Assignment Help JAVA Programming
Reference no: EM132057236

11. 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 TestSandwich that instantiates one Sandwich object and demonstrates the use of the set and get methods. Save this application as TestSandwich.java.

12. a. Create a class named Student. A Student has fields for an ID number, number of credit hours earned, and number of points earned. (For example, many schools compute grade point averages based on a scale of 4, so a three-credit-hour class in which a student earns an A is worth 12 points.) Include methods to assign values to all fields. A Student also has a field for grade point average. Include a method to compute the grade point average field by dividing points by credit hours earned. Write methods to display the values in each Student field. Save this class as Student.java.

b. Write a class named ShowStudent that instantiates a Student object from the class you created and assign values to its fields. Compute the Student grade point average, and then display all the values associated with the Student. Save the application as ShowStudent.java.

c. Create a constructor for the Student class you created. The constructor should initialize each Student's ID number to 9999, his or her points earned to 12, and credit hours to 3 (resulting in a grade point average of 4.0). Write a program that demonstrates that the constructor works by instantiating an object and displaying the initial values. Save the application as ShowStudent2.java.

13. 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. 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.

Reference no: EM132057236

Questions Cloud

Write program to read a text file and to count the number : Write program to read a text file and to count the number of lines and characters in the file (do not include the new line characters in the character count). d
Command line arguments are passed to the main method : Command line arguments are passed to the main method through the array of String references (args in the main method below).
What is a variable scope : What is a variable scope and how is it used in java? Please provide examples.
What is exception propagation : What is exception propagation? Give a code example of a class that contains at least two methods
Create a class named sandwich : 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")
User for the name of a tennis player : Ask the user for the number of years the tennis player has played competitive tennis.Use this value as the size of a double array.
Arraylist-binary search-i-o streams-exceptions : Read in a text file from standard input, censor it, and print out the result to standard output. To censor the file, first read in a list of words from the file
Files in java runtime environment : Why is it important to eliminate need to configure files in java runtime environment
Local running group held a one hour track event : A local running group held a one hour track event where people tried to comple.te as many miles as they could in one hour. The times were recorded

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create a java program the displays the state bird and flower

Write a Java program the displays the State bird and flower. The program should prompt the user to enter a State and print both the State bird and flower.

  What are the three required expressions of a for-loop

What are the three required expressions of a for-loop. Consider the following code. This code was written to generate the output as shown in

  Compilers check programs for syntax errors

Compilers check programs for syntax errors, but frequently a lack of one symbol (such as a missing brace or comment starter) will cause the compiler to spill out a number of diagnostics without identifying the real error

  Create a gui front end for your bubble sort program

Design and implement a Java program which sorts a 10 element integer array using the bubble sort process. The elements of the array to be sorted should be supplied by the user (assume the user will not input duplicates).

  Lists the number of appointments

Create a query that lists the number of appointments for each doctor by day. Display the number of appointments, the doctor ID, and the appointment date. Display the output in order of doctor ID with the lowest doctor ID first.

  Create a new project called fractions

You are going to write an API for a Fractions class. It will accept fractions as input and perform various mathematical operations on them -  Create a new project called Fractions. Within Fractions, create a new class called Fraction. NetBeans will..

  Finish off the powerball application

Finish off the Powerball application - Enter the number into array - For each value of number

  Code to read a csv file

You have the code to read a .csv file but now you need to prompt the user to pick an option 1-5 - Next you have to assoicate the users input with the answer

  Write programs that read a line of input

Write programs that read a line of input as a string and input

  Writing a program to manage a student database

Writing a program to manage a student database. The interface to the program should be a GUI that looks similar to the following: A combo box should allow the user to select one of the three database actions shown

  Rogram that will accept input and then display values

The program should continue as long as the user enters any values, even if only spaces are entered. Figure 9-49 (attached to post) displays sample output from the program.

  Project amount of total sales

Write a program called sales_prediction.js, that displays the profit based on the project amount of total sales for the year. Use a literal value of $2,500,000 for the projected total sales amount. Display the profit amount formatted to two decima..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd