JAVA: Debit Card Reader (interfaces) CashRegister.java                         is the ONLY FILE the can be edited!!!! Many machines are able to make use of debit cards in order for people to make transactions using the money in their bank accounts. One piece of a debit card's security is its PIN number, which must be entered correctly for a transaction to proceed. The main() program below defines a cash register and a debit card with the pin 1234, and then accepts a PIN number as input. The entered PIN number is passed to the cash register along with the debit card object to verify that the entered PIN was correct. Given main(), a DebitCard class, and a DebitCardReader interface, complete the definition for the CashRegister class. The CashRegister class should provide a definition for the abstract method from the interface it implements. The program will be complete once this abstract method is defined correctly. Ex. If the input is: 1234 the output should be: Transaction succeeded! If the input is: 1111 the output should be: Transaction failed.     Templet files:  Transaction.java import java.util.Scanner; public class Transaction {   public static void main(String[] args) {      Scanner scnr = new Scanner(System.in);            CashRegister register = new CashRegister();      DebitCard card = new DebitCard(1234);            int pin;            pin = scnr.nextInt();            if (register.verifyCardPIN(card, pin)) {         System.out.println("Transaction succeeded!");      }      else {         System.out.println("Transaction failed.");      }   }} DebitCard.java public class DebitCard {   private int pin;      public DebitCard(int newpin) {      pin = newpin;   }      public int getPIN() {      return pin;   }      public void setPIN(int newpin) {      pin = newpin;   }} DebitCardReader.java public interface DebitCardReader {   public boolean verifyCardPIN(DebitCard card, int pin);} CashRegister.java public class CashRegister implements DebitCardReader {

Oh no! Our experts couldn't answer your question.

Don't worry! We won't leave you hanging. Plus, we're giving you back one question for the inconvenience.

Submit your question and receive a step-by-step explanation from our experts in as fast as 30 minutes.
You have no more questions left.
Message from our expert:
Our experts are unable to provide you with a solution at this time. Try rewording your question, and make sure to submit one question at a time. We've credited a question to your account.
Your Question:

JAVA: Debit Card Reader (interfaces)

CashRegister.java                         is the ONLY FILE the can be edited!!!!

Many machines are able to make use of debit cards in order for people to make transactions using the money in their bank accounts. One piece of a debit card's security is its PIN number, which must be entered correctly for a transaction to proceed. The main() program below defines a cash register and a debit card with the pin 1234, and then accepts a PIN number as input. The entered PIN number is passed to the cash register along with the debit card object to verify that the entered PIN was correct.

Given main(), a DebitCard class, and a DebitCardReader interface, complete the definition for the CashRegister class. The CashRegister class should provide a definition for the abstract method from the interface it implements. The program will be complete once this abstract method is defined correctly.

Ex. If the input is:

1234

the output should be:

Transaction succeeded!

If the input is:

1111

the output should be:

Transaction failed.
 
 
Templet files: 
Transaction.java

import java.util.Scanner;

public class Transaction {
   public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      
      CashRegister register = new CashRegister();
      DebitCard card = new DebitCard(1234);
      
      int pin;
      
      pin = scnr.nextInt();
      
      if (register.verifyCardPIN(card, pin)) {
         System.out.println("Transaction succeeded!");
      }
      else {
         System.out.println("Transaction failed.");
      }
   }
}

DebitCard.java

public class DebitCard {
   private int pin;
   
   public DebitCard(int newpin) {
      pin = newpin;
   }
   
   public int getPIN() {
      return pin;
   }
   
   public void setPIN(int newpin) {
      pin = newpin;
   }
}

DebitCardReader.java

public interface DebitCardReader {
   public boolean verifyCardPIN(DebitCard card, int pin);
}

CashRegister.java

public class CashRegister implements DebitCardReader {

 

Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning