Write a class named retailitem that holds data

Assignment Help JAVA Programming
Reference no: EM131475856

Problem 1:

Implement a class Address. An address has a house number, a street, an optional apartment number, a city, a state, and a postal code. Supply two constructors: one with an apartment number and one without. Supply a print method that prints the address with the street on one line and the city, state, and postal code on the next line. Supply a method public boolean comesBefore (Address other) that tests whether this address comes before another when the addresses are compared by postal code.

Problem 2:

Implement a class with methods getSurfaceArea() and getVolume(). In the constructor supply the height and radius of the can.

Problem 3:

Month Class Write a class named Month. The class should have an int field named monthNumber that holds the number of the month. For example, January would be 1, February would be 2, and so forth. In addition, provide the following methods:

A no-arg constructor that sets the monthNumber field to 1.

A constructor that accepts the number of the month as an argument. It should set the monthNumber field to the value passed as the argument. If a value less than 1 or greater than 12 is passed, the constructor should set monthNumber to 1.

A constructor that accepts the name of the month, such as "January" or "February" as an argument. It should set the monthNumber field to the correct corresponding value.

A setMonthNumber method that accepts an int argument, which is assigned to the monthNumber field. If a value less than 1 or greater than 12 is passed, the method should set monthNumber to 1.

A getMonthNumber method that returns the value in the monthNumber field.

A getMonthName method that returns the name of the month. For example, if the monthNumber field contains 1, then this method should return "January".

A toString method that returns the same value as the getMonthName method.

An equals method that accepts a Month object as an argument. If the argument object holds the same data as the calling object, this method should return true. Otherwise, it should return false.

A greaterThan method that accepts a Month object as an argument. If the calling object's monthNumber field is greater than the argument's monthNumber field, this method should return true. Otherwise, it should return false.

A lessThan method that accepts a Month object as an argument. If the calling object's monthNumber field is less than the argument's monthNumber field, this method should return true. Otherwise, it should return false.

Problem 4:

Implement a class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon) and a certain amount of fuel in the gas tank. The efficiency is specified in the constructor, and the initial fuel level is 0. Supply a method drive that simulates driving the car for a cartain distance, reducing the fuel level in the gas tank, and methods getGasLevel, to return the current fuel level and addGas, to tank up. Sample usage:

Car myHybrid = new Car(50); //50 miles per gallon

myHybrid.addGas(20); // Tank 20 gallons

myHybrid.drive(100); // Drive 100 miles

System.out.println(myHybrid>.getGasLevel()); // Print fuel remaining.

Problem 5:

RetailItem Class Write a class named RetailItem that holds data about an item in a retail store. The class should have the following fields:

description. The description field references a String object that holds a brief description of the item.

units OnHand. The unitsOnHand field is an int variable that holds the number of units currently in inventory.

price. The price field is a double that holds the item's retail price.

Write a constructor that accepts arguments for each field, appropriate mutator methods that store values in these fields, and accessor methods that return the values in these fields. Once you have written the class, write a separate program that creates three RetailItem objects and stores the following data in them:

Description

Unitson Hand

Price

Item #1

Jacket

12

59.95

Item #2

Designer Jeans

40

34.95

Item #3

Shirt

20

24.95

Reference no: EM131475856

Questions Cloud

Write a c language program to generate a square wave on pin : Write a C language program to generate a square wave on pin 3 of PORTC with a 4 ms period using Timer3 in 16-bit mode with a prescaler value of 1:8.
Employee expectations for the workplace environment : change in organizational structure and employee expectations for the workplace environment.
Weight-loss program consisting of food products-diet pills : Kristoph incorporated Hi-Energy, Inc., which was a weight-loss program consisting of food products, diet pills, group meetings, and exercise classes.
Organization job evaluation system : Can an organization's job evaluation system become a limiting factor for the overall welfare of the organization? If so, how? If not, how come?
Write a class named retailitem that holds data : RetailItem Class Write a class named RetailItem that holds data about an item in a retail store. Write a constructor that accepts arguments for each field
Aspect of a health care facility culture : Determine a key aspect of a health care facility's culture that is necessary to support the implementation of an integrated delivery system.
Write a c language program to turn an led on : Write a C language program to turn an LED ON connected at bit 0 of PORTC when the TMR2 reaches a value of 200. Assume a 4 MHz crystal.
Explain context in which balanced scorecard would be used : Describe the context in which the Balanced Scorecard and the IT framework would be used. The paper should 3-4 pages in APA format, not counting the title and re
Display the number of registrations : You create a report to display the registration counts by CampusID and by TermYear. You then change the report to display the number of registrations.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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