ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 08 May 2017 My Price 9.00

Java interface

Java interface question

The payment transaction scenario could be represented by the following hierarchy:

        Payment
VISA            Master
          Debit

Create interface class Payments with one abstract method called paymentInfo.
· Create classes VISA, MASTER, DEBIT that implement Payments.
· For each of the three classes (VISA, MASTER, DEBIT), create one constructor, one instant variable amount, and get balance method.
· Constructors are used to create objects with initial balance.
· The interface class method “paymentInfo” should be overridden in the three classes (VISA, MASTER, DEBIT) to display the initial amount of each object.
· paymentInfo method is used to display information on the screen about the current amount.

· You test method should looks like:

public class Demo {
public static void main(String args[]) {
/* Create two objects using constructor */
Payments visaPymts = new VISA(100);
Payments masterPymts = new MASTER(200);
Payments debitPymts = new DEBIT(400);
// Invoking a method for each object created
visaPymts.paymentInfo ();
masterPymts.paymentInfo ();
debitPymts.paymentInfo ();
double totalAmount = visaPymts.getAmount() + visaPymts.getAmount() + visaPymts.getAmount();
System,out.println(“The total amount you paid is” + totalAmount);
}
}

· The output of the program will be like the following:
You paid $100.00 using your VISA card
You paid $200.00 using your MASTER card
You paid $400.00 using your DEBIT card.
The total amount you paid is $700

 

Attachments:

Answers

(11)
Status NEW Posted 08 May 2017 04:05 AM My Price 9.00

-----------

Not Rated(0)