diff --git a/.classpath b/.classpath
new file mode 100644
index 00000000..c8ffe1c0
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 00000000..a3a2e917
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ CashRegister
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..8aabe8df
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,14 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=16
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=16
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=16
diff --git a/Input.txt b/Input.txt
new file mode 100644
index 00000000..80d6c9ce
--- /dev/null
+++ b/Input.txt
@@ -0,0 +1,10 @@
+100 , 99
+1,1
+2,100
+20,30
+2.12,3.00
+1.97,2.00
+3.33,5.00
+1.85,2.00
+1.67,2.00
+0.70,1.00
\ No newline at end of file
diff --git a/README.md b/README.md
index 62a96fc3..c131662e 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,9 @@
Cash Register
============
+This project is written in Java with a JUnit test class. It takes in a flat file with a list of prices and payments, and outputs the change, as a String, to a Receipt.txt file. In most cases, the least amount of physical change is returned, however, if the total due in cents is divisible by 3, the application randomly generates the change denominations. Below is the original problems and criteria for the application.
+
+
The Problem
-----------
Creative Cash Draw Solutions is a client who wants to provide something different for the cashiers who use their system. The function of the application is to tell the cashier how much change is owed and what denominations should be used. In most cases the app should return the minimum amount of physical change, but the client would like to add a twist. If the total due in cents is divisible by 3, the app should randomly generate the change denominations (but the math still needs to be right :))
diff --git a/Receipt.txt b/Receipt.txt
new file mode 100644
index 00000000..df3b65c2
--- /dev/null
+++ b/Receipt.txt
@@ -0,0 +1,10 @@
+Insufficient Funds
+Exact Change Given
+1 FIFTIES. 2 TWENTIES. 1 FIVE(S). 3 ONE(S).
+1 TEN(S).
+3 QUARTER(S). 1 DIME(S). 3 PENNIES.
+3 PENNIES.
+1 ONE(S). 2 QUARTER(S). 1 DIME(S). 1 NICKEL(S). 2 PENNIES.
+3 NICKEL(S).
+33 PENNIES.
+6 NICKEL(S).
diff --git a/bin/.gitignore b/bin/.gitignore
new file mode 100644
index 00000000..ec88932a
--- /dev/null
+++ b/bin/.gitignore
@@ -0,0 +1,2 @@
+/test/
+/Register/
diff --git a/bin/io/MoneyReader.class b/bin/io/MoneyReader.class
new file mode 100644
index 00000000..9c509b1a
Binary files /dev/null and b/bin/io/MoneyReader.class differ
diff --git a/bin/io/MoneyWriter.class b/bin/io/MoneyWriter.class
new file mode 100644
index 00000000..ff45d11d
Binary files /dev/null and b/bin/io/MoneyWriter.class differ
diff --git a/src/Register/Change.java b/src/Register/Change.java
new file mode 100644
index 00000000..d7a9c985
--- /dev/null
+++ b/src/Register/Change.java
@@ -0,0 +1,228 @@
+package Register;
+
+import java.text.DecimalFormat;
+
+/**
+ * The Change class calculates how much of each bill and coin
+ * are needed to makeup the change to be given back.
+ *
+ * @author chasekeady
+ *
+ */
+public class Change {
+ private int hundreds;
+ private int fifties;
+ private int twenties;
+ private int tens;
+ private int fives;
+ private int ones;
+ private int quarters;
+ private int dimes;
+ private int nickels;
+ private int pennies;
+ private String cashBack;
+ private DecimalFormat df;
+
+
+ /**
+ * Standard constructor for the Change class
+ *
+ * @param df - formats doubles in class to 2 decimal places
+ */
+ public Change(DecimalFormat df){
+ this.df = df;
+ }
+
+ /**
+ * Calculates how many hundred dollar bills are needed to make the change
+ * to be given back. Returns how much change is left after hundred dollar
+ * bills are accounted for.
+ *
+ * @param change - amount needed to be returned
+ */
+ public double hundreds(double change) {
+ if((int)(change/100) > 0){
+ hundreds = (int)(change/100);
+ change = Double.valueOf(df.format(change - (hundreds * 100)));
+ }
+ return change;
+ }
+
+ /**
+ * Calculates how many fifty dollar bills are needed to make the change
+ * to be given back. Returns how much change is left after fifty dollar
+ * bills are accounted for.
+ *
+ * @param change - amount needed to be returned
+ */
+ public double fifties(double change) {
+ if((int)(change/50) >0){
+ fifties = (int)(change/50);
+ change = Double.valueOf(df.format(change - (fifties * 50)));
+ }
+ return change;
+ }
+
+ /**
+ * Calculates how many twenty dollar bills are needed to make the change
+ * to be given back. Returns how much change is left after twenty dollar
+ * bills are accounted for.
+ *
+ * @param change - amount needed to be returned
+ */
+ public double twenties(double change) {
+ if((int)(change/20) >0){
+ twenties = (int)(change/20);
+ change = Double.valueOf(df.format(change - (twenties * 20)));
+ }
+ return change;
+ }
+
+ /**
+ * Calculates how many ten dollar bills are needed to make the change
+ * to be given back. Returns how much change is left after ten dollar
+ * bills are accounted for.
+ *
+ * @param change - amount needed to be returned
+ */
+ public double tens(double change) {
+ if((int)(change/10) >0){
+ tens = (int)(change/10);
+ change = Double.valueOf(df.format(change - (tens * 10)));
+ }
+ return change;
+ }
+
+ /**
+ * Calculates how many five dollar bills are needed to make the change
+ * to be given back. Returns how much change is left after five dollar
+ * bills are accounted for.
+ *
+ * @param change - amount needed to be returned
+ */
+ public double fives(double change) {
+ if((int)(change/5) >0){
+ fives = (int)(change/5);
+ change = Double.valueOf(df.format(change - (fives * 5)));
+ }
+ return change;
+ }
+
+ /**
+ * Calculates how many one dollar bills are needed to make the change
+ * to be given back. Returns how much change is left after one dollar
+ * bills are accounted for.
+ *
+ * @param change - amount needed to be returned
+ */
+ public double ones(double change) {
+ if(change-1 >= 0) {
+ ones = 0;
+ while(change >= 1) {
+ change = Double.valueOf(df.format(change -1));
+ ones++;
+ }
+ }
+ return change;
+ }
+
+ /**
+ * Calculates how many quarters are needed to make the change
+ * to be given back. Returns how much change is left after the
+ * quarters are accounted for.
+ *
+ * @param change - amount needed to be returned
+ */
+ public double quarters(double change) {
+ if((int)(change/.25) > 0) {
+ quarters = (int)((change*100)/(.25*100));
+ change = Double.valueOf(df.format(change - (quarters * .25)));
+ }
+ return change;
+ }
+
+ /**
+ * Calculates how many dimes are needed to make the change
+ * to be given back. Returns how much change is left after the
+ * dimes are accounted for.
+ *
+ * @param change - amount needed to be returned
+ */
+ public double dimes(double change) {
+ if((int)(change/.10) > 0) {
+ dimes = (int)((change*100)/(.10*100));
+ change = Double.valueOf(df.format(change - (dimes * .10)));
+ }
+ return change;
+ }
+
+ /**
+ * Calculates how many nickels are needed to make the change
+ * to be given back. Returns how much change is left after the
+ * nickels are accounted for.
+ *
+ * @param change - amount needed to be returned
+ */
+ public double nickels(double change) {
+ if((int)(change/.05) > 0) {
+ nickels = (int)((change*100)/(.05*100));
+ change = Double.valueOf(df.format(change - (nickels * .05)));
+ }
+ return change;
+ }
+
+ /**
+ * Calculates how many pennies are needed to make the change
+ * to be given back. Returns how much change is left after the
+ * pennies are accounted for.
+ *
+ * @param change - amount needed to be returned
+ */
+ public double pennies(double change) {
+ if((int)(change/.01) > 0) {
+ pennies = (int)(change/.01);
+ change = change - (pennies * .01);
+ }
+ return change;
+ }
+
+ /**
+ * Returns a string that contains the bills and coins that makeup
+ * the change needed to be handed back.
+ */
+ public String printChange() {
+ cashBack = "";
+ if(hundreds != 0){
+ cashBack += hundreds + " HUNDRED(S). ";
+ }
+ if(fifties != 0){
+ cashBack += fifties + " FIFTIES. ";
+ }
+ if(twenties != 0){
+ cashBack += twenties + " TWENTIES. ";
+ }
+ if(tens != 0){
+ cashBack += tens + " TEN(S). ";
+ }
+ if(fives != 0){
+ cashBack += fives + " FIVE(S). ";
+ }
+ if(ones != 0){
+ cashBack += ones + " ONE(S). ";
+ }
+ if(quarters != 0){
+ cashBack += quarters + " QUARTER(S). ";
+ }
+ if(dimes != 0){
+ cashBack += dimes + " DIME(S). ";
+ }
+ if(nickels != 0){
+ cashBack += nickels + " NICKEL(S). ";
+ }
+ if(pennies != 0){
+ cashBack += pennies + " PENNIES. ";
+ }
+
+ return cashBack;
+ }
+}
diff --git a/src/Register/Register.java b/src/Register/Register.java
new file mode 100644
index 00000000..a2ca5bd5
--- /dev/null
+++ b/src/Register/Register.java
@@ -0,0 +1,143 @@
+package Register;
+
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Random;
+
+import io.MoneyReader;
+import io.MoneyWriter;
+
+/**
+ * The Register class holds the main method for the CashRegister project.
+ * The class first loads the input file that contains a price and amount paid,
+ * then calculates the change that is needed to be given back. Once the change is
+ * calculated, it is printed to a Receipt.txt file.
+ *
+ * @author chasekeady
+ *
+ */
+public class Register {
+
+ /**
+ * The main method for the CashRegister project. This method will loop
+ * through a list of change and prints the result to Receipt.txt
+ *
+ * @param args
+ * @throws IOException
+ */
+ public static void main(String[] args) throws IOException {
+ try {
+ Register register = new Register();
+ MoneyWriter moneyWriter = new MoneyWriter("Receipt.txt");
+ ArrayList change = new ArrayList();
+
+ change = register.payments("Input.txt");
+
+ for (int counter = 0; counter < change.size(); counter++) {
+ String cashBack = register.outputChange(change.get(counter));
+ System.out.println(cashBack);
+ moneyWriter.writeChange(cashBack);
+ }
+
+ moneyWriter.close();
+ }catch(Exception e) {
+ System.out.println(e);
+ }
+ }
+
+ /**
+ * Reads price and amount from Input.txt file, calculates the change
+ * that is needed to be handed back, and inserts that value into an ArrayList.
+ * The ArrayList is then returned.
+ *
+ * @param fileName - the name of the file the payment are loaded from
+ * @throws IOException
+ */
+ public ArrayList payments(String fileName) throws IOException{
+ ArrayList change = new ArrayList();
+ MoneyReader moneyReader = new MoneyReader(fileName);
+ String line;
+
+ while((line = moneyReader.readPayment()) != null) {
+ DecimalFormat df = new DecimalFormat("#.##");
+
+ double price = Double.parseDouble(line.split(",")[0].trim());
+ double amountGiven = Double.parseDouble(line.split(",")[1].trim());
+
+ double diff = Double.valueOf(df.format(amountGiven - price));
+
+ change.add(diff);
+ }
+
+ moneyReader.close();
+ return change;
+ }
+
+ /**
+ * Returns a string that contains the bills and coins that makeup
+ * the change needed to be handed back.
+ *
+ * @param change - amount needed to be returned
+ * @throws IOException
+ */
+ public String outputChange(double change) throws IOException {
+ if(change < 0) {
+ String cashBack = "";
+ cashBack= "Insufficient Funds";
+ return cashBack;
+ }else if(change == 0) {
+ String cashBack = "";
+ cashBack = "Exact Change Given";
+ return cashBack;
+ }else {
+ //Calculates how many of each bill are needed to makeup the change
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change cashBack = new Change(df);
+ while(change >= 1) {
+ change = cashBack.hundreds(change);
+ change = cashBack.fifties(change);
+ change = cashBack.twenties(change);
+ change = cashBack.tens(change);
+ change = cashBack.fives(change);
+ change = cashBack.ones(change);
+ }
+
+ //If change in cents is divisible by 3, the change given back will be random
+ if((change != 0) && (((change * 100) % 3) == 0)) {
+ Random rand = new Random();
+ int[] cases = {1, 5, 10, 25};
+ while(change >0) {
+ int i = cases[rand.nextInt(4)];
+ switch(i) {
+ case 1:
+ change = cashBack.pennies(change);
+ break;
+ case 5:
+ change = cashBack.nickels(change);
+ break;
+ case 10:
+ change = cashBack.dimes(change);
+ break;
+ case 25:
+ change = cashBack.quarters(change);
+ break;
+ }
+
+ }
+ }
+ //If the change, in cents, is not divisible by 3, the minimum amount of coins will be returned
+ else {
+ while(change > 0) {
+ change = cashBack.quarters(change);
+ change = cashBack.dimes(change);
+ change = cashBack.nickels(change);
+ change = cashBack.pennies(change);
+ }
+ }
+
+ return cashBack.printChange();
+ }
+ }
+
+}
diff --git a/src/io/MoneyReader.java b/src/io/MoneyReader.java
new file mode 100644
index 00000000..327d2fd8
--- /dev/null
+++ b/src/io/MoneyReader.java
@@ -0,0 +1,47 @@
+package io;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+
+/**
+ * The MoneyReader class reads in all the prices and payments into the project
+ *
+ * @author chasekeady
+ *
+ */
+public class MoneyReader {
+
+ private BufferedReader in;
+
+ /**
+ * Standard constructor for creating a MoneyReader
+ *
+ * @param fileName - the name of the file that will be read from
+ * @throws FileNotFoundException
+ */
+ public MoneyReader(String fileName) throws FileNotFoundException {
+ in = new BufferedReader(new FileReader(fileName));
+ }
+
+ /**
+ * Reads in a line from the file
+ *
+ * @throws IOException
+ */
+ public String readPayment() throws IOException {
+ String line = in.readLine();
+ return line;
+
+ }
+
+ /**
+ * Closes the MoneyReader instance
+ *
+ * @throws IOException
+ */
+ public void close() throws IOException {
+ in.close();
+ }
+}
diff --git a/src/io/MoneyWriter.java b/src/io/MoneyWriter.java
new file mode 100644
index 00000000..f986b355
--- /dev/null
+++ b/src/io/MoneyWriter.java
@@ -0,0 +1,37 @@
+package io;
+
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class MoneyWriter {
+
+ private PrintWriter out;
+
+ /**
+ * Standard constructor for creating a MoneyWriter
+ *
+ * @param fileName - the name of the new file
+ * @throws IOException
+ */
+ public MoneyWriter(String fileName) throws IOException{
+ out = new PrintWriter(new FileWriter(fileName));
+ }
+
+ /**
+ * Writes a line to the new file
+ */
+ public void writeChange(String output) {
+ out.println(output);
+ }
+
+ /**
+ * Closes the MoneyWriter instance
+ *
+ * @throws IOException
+ */
+ public void close() throws IOException {
+ out.close();
+ }
+}
diff --git a/src/test/ChangeTest.java b/src/test/ChangeTest.java
new file mode 100644
index 00000000..dc60e9aa
--- /dev/null
+++ b/src/test/ChangeTest.java
@@ -0,0 +1,274 @@
+package test;
+
+import static org.junit.Assert.*;
+import java.text.DecimalFormat;
+import Register.Change;
+import org.junit.jupiter.api.Test;
+
+/*
+ * Test class for the Change class
+ */
+class ChangeTest {
+
+ @Test
+ void testHundredsNoRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.hundreds(100.00);
+
+ assertEquals(0.0,result,0.0);
+ }
+
+ @Test
+ void testHundredsRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.hundreds(150.00);
+
+ assertEquals(50.0,result,0.0);
+ }
+
+ @Test
+ void testNoHundreds() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.hundreds(99.00);
+
+ assertEquals(99.0,result,0.0);
+ }
+
+ @Test
+ void testFiftiesNoRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.fifties(50.00);
+
+ assertEquals(0.0,result,0.0);
+ }
+
+ @Test
+ void testFiftiesRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.fifties(60.00);
+
+ assertEquals(10.0,result,0.0);
+ }
+
+ @Test
+ void testNoFifties() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.fifties(49.00);
+
+ assertEquals(49.0,result,0.0);
+ }
+
+ @Test
+ void testTwentiesNoRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.twenties(20.00);
+
+ assertEquals(0.0,result,0.0);
+ }
+
+ @Test
+ void testTwentiesRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.twenties(30.00);
+
+ assertEquals(10.0,result,0.0);
+ }
+
+ @Test
+ void testNoTwenties() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.twenties(15.00);
+
+ assertEquals(15.0,result,0.0);
+ }
+
+ @Test
+ void testTensNoRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.tens(100.00);
+
+ assertEquals(0.0,result,0.0);
+ }
+
+ @Test
+ void testTensRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.tens(25.00);
+
+ assertEquals(5.0,result,0.0);
+ }
+
+ @Test
+ void testNoTens() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.tens(9.00);
+
+ assertEquals(9.0,result,0.0);
+ }
+
+ @Test
+ void testFivesNoRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.fives(10.00);
+
+ assertEquals(0.0,result,0.0);
+ }
+
+ @Test
+ void testFivesRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.fives(11.00);
+
+ assertEquals(1.0,result,0.0);
+ }
+
+ @Test
+ void testNoFives() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.fives(4.00);
+
+ assertEquals(4.0,result,0.0);
+ }
+
+ @Test
+ void testOnesNoRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.ones(1.00);
+
+ assertEquals(0.0,result,0.0);
+ }
+
+ @Test
+ void testOnesRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.ones(1.50);
+
+ assertEquals(0.50,result,0.0);
+ }
+
+ @Test
+ void testNoOnes() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.ones(0.99);
+
+ assertEquals(0.99,result,0.0);
+ }
+
+ @Test
+ void testQuartersNoRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.quarters(0.50);
+
+ assertEquals(0.0,result,0.0);
+ }
+
+ @Test
+ void testQuartersRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.quarters(0.51);
+
+ assertEquals(0.01,result,0.0);
+ }
+
+ @Test
+ void testNoQuarters() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.quarters(0.24);
+
+ assertEquals(0.24,result,0.0);
+ }
+
+ @Test
+ void testDimesNoRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.dimes(0.90);
+
+ assertEquals(0.0,result,0.0);
+ }
+
+ @Test
+ void testDimesRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.dimes(0.95);
+
+ assertEquals(0.05,result,0.0);
+ }
+
+ @Test
+ void testNoDimes() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.dimes(0.09);
+
+ assertEquals(0.09,result,0.0);
+ }
+
+ @Test
+ void testNickelsNoRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.nickels(0.15);
+
+ assertEquals(0.0,result,0.0);
+ }
+
+ @Test
+ void testNickelsRemainder() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.nickels(0.16);
+
+ assertEquals(0.01,result,0.0);
+ }
+
+ @Test
+ void testNoNickels() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.nickels(0.04);
+
+ assertEquals(0.04,result,0.0);
+ }
+
+ @Test
+ void testPennies() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.pennies(0.10);
+
+ assertEquals(0.0,result,0.0);
+ }
+
+ @Test
+ void testNoPennies() {
+ DecimalFormat df = new DecimalFormat("#.##");
+ Change change = new Change(df);
+ double result = change.pennies(0.00);
+
+ assertEquals(0.0,result,0.0);
+ }
+
+}
diff --git a/src/test/RegisterTest.java b/src/test/RegisterTest.java
new file mode 100644
index 00000000..ccecb27c
--- /dev/null
+++ b/src/test/RegisterTest.java
@@ -0,0 +1,43 @@
+package test;
+
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.junit.jupiter.api.Test;
+
+import Register.Register;
+
+/*
+ * Test class for Register Class
+ */
+class RegisterTest {
+
+ @Test
+ void testPayments() throws IOException {
+ Register register = new Register();
+ ArrayList change = register.payments("Input.txt");
+ int len = change.size();
+
+ assertEquals(10,len);
+ }
+
+ @Test
+ void testOutPutChangeBills() throws IOException {
+ Register register = new Register();
+ String output = register.outputChange(186.00);
+ String result = "1 HUNDRED(S). 1 FIFTIES. 1 TWENTIES. 1 TEN(S). 1 FIVE(S). 1 ONE(S). ";
+ assertTrue(output.equals(result));
+ }
+
+ @Test
+ void testOutPutChangeCents() throws IOException {
+ Register register = new Register();
+ String output = register.outputChange(0.41);
+ String result = "1 QUARTER(S). 1 DIME(S). 1 NICKEL(S). 1 PENNIES. ";
+ assertTrue(output.equals(result));
+ }
+
+}