Explore BrainMass
Share

Java Classes Payment, Cash Payment, and Credit Card Payment

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Define a class named Payment that contains a member variable of type double that stores the amount of the payment and appropriate accessor and mutator methods. Also, create a method named paymentDetails that outputs an English sentence to describe the amount of the payment. Next, define a class named CashPayment that is derived from Payment. This class should redefine the paymentDetails method to indicate that the payment is in cash. Include appropriate constructor(s). Define a class named CreditCardPayment that is derived from Payment. This class should contain member variables for the name on the card, expiration date, and credit card number. Include appropriate constructor(s). Finally, redefine the paymentDetails method to include all credit card information in the printout. Create a main method that creates at least two CashPayment and two CreditCardPayment objects
with different values and calls paymentDetails for each.

CodeMate Hints
/**
* This program introduces inheritance through a problem of
* creating two types of Payments, Cash and Credit. The
* paymentDetails method outputs in English a sentence that describes
* the payment.
*/
/**
* Base class that holds payment amount provides a method for returning
* a description of the payment.
*/
public class Payment
{
//Payment amount
private double amount;
//Constructor to initialize amount to 0
public Payment()
{
amount = 0.0;
}
/**
* Constructor to initialize payment amount
*/
public Payment(double paymentAmount)
{
amount = paymentAmount;
}
/**
* Sets the payment amount
*/
public void setPayment(double paymentAmount)
{
amount = paymentAmount;
}
/**
* Returns the payment amount
*/
public double getPayment()
{
return amount;
}
/**
* Prints a description of the payment
*/
public void paymentDetails()
{
System.out.println("The payment amount is " + amount);
}
public static void main(String[] args)
{
// Create several test classes and invoke the paymentDetails method
Payment cash1 = new CashPayment(50.5);
Payment cash2 = new CashPayment(20.45);
Payment credit1 =
new CreditCardPayment(10.5, "Fred", "10/5/2010", "123456789");
Payment credit2 =
new CreditCardPayment(100, "Barney", "11/15/2009", "987654321");
System.out.println("Cash 1 details:");
cash1.paymentDetails();
System.out.println();
System.out.println("Cash 2 details:");
cash2.paymentDetails();
System.out.println();
System.out.println("Credit 1 details:");
credit1.paymentDetails();
System.out.println();
System.out.println("Credit 2 details:");
credit2.paymentDetails();
System.out.println();
}
}

© BrainMass Inc. brainmass.com October 25, 2018, 10:11 am ad1c9bdddf
https://brainmass.com/computer-science/java/java-classes-cash-payment-credit-card-601665

Solution Preview

Please rename attached 601665-Payment.java to Payment.java before you compile and execute the program.
Java and Java compiler version 1.7.0_04 were used during development and ...

Solution Summary

Java and Java compiler version 1.7.0_04 were used during development and testing of the attached program. Response mentions how the program can be compiled and tested at command line.

$2.19
See Also This Related BrainMass Solution

Managment Information Systems for a Grocery Store

1. You have been hired to create a new checkout system for a grocery chain. It wants to put scanners into the shopping carts and have shoppers scan their own products. The system will track the basic purchases by customers so that it can offer discounts and recommend related products based on current and past purchases. You need to find a way for people to pay for their purchases. You want to minimize theft, but one of the goals is to reduce costs by fewer checkout clerks. Create an initial design for this system.

2. For each of the following information system projects, identify the method (system development methodologies: SDLC, prototyping, RAD, JAD, open source, objects, end user) that would be the best approach for most companies:

a. A new system to track customer requests and comments for the marketing department at a large ski manufacturer.

b. A system to help managers evaluate regional sales data, from the existing sales system running on an Oracle database.

c. A system to track current location and maintenance status of thousands of baggage carts at an airport.

d. A web site to sell "homemade" dog treats over the Internet for a small business.

e. A scientific system to help astronomers collect data from colleagues, track specific items (e.g. comets), and send announcements and questions over the Internet to a group of registered users.

f. A system to help a group of financial managers monitor client transactions and observe them for potentially illegal patterns such as insider trading.

g. A system running on one PC that connects to a truck scale and records incoming shipments of recyclable materials.

h. A system for a manager that pulls data on cell phone usage from all of his workers. It groups the calls and costs so that he can see if workers are making too many personal phone calls.

3. Assume that you are on a project to build a new Web site for a midsize company. The firm sells materials to home builders- usually contractors, but some individual sales as well. The company wants to take orders over the web and enable customers to track the status of current orders. Contractors also want the ability to look at old orders when placing new ones. For example, if they build the same style house twice, they will need approximately the same materials. The manufacturer is not completely certain on many of the details yet, and you will have to interview customers to get additional details and feedback. Setup a schedule for developing this system using the SDLC approach. Then identify ways that RAD might be used to reduce the overall development time.

4. Make a list of symptoms you expect to see in a company that has centralized databases and MIS personnel, but has just decentralized its departments and users have just bought hundreds of new personal computers in the last three years.

5. Make a list of symptoms you expect to see in a company that is too decentralized. That is, the company users are free to choose any hardware and software, and databases are maintained by each department. Data is shared through reports that are printed in each department and forwarded to other departments on paper. There is no central MIS staff and no CIO. Treat it as a company that started small using personal computers and grew but did not come up with centralized information system approach.

6. Write a plan for moving a midsize service company to an intranet and mobile-commerce-based information system, where as many applications as possible will run through browsers and data will be accessible from anywhere in the company. What technologies will you use? What functions will you centralize of decentralize? How will you provide adequate security?

Identify on a high level, the major systems involved; specify the aspects of the systems that can be decentralized or will need to be centralized; identify ways to handle them.

View Full Posting Details