Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

?Develop a Java Program to solve the given problem. The Denver Urban Sports Tech

ID: 3687106 • Letter: #

Question

?Develop a Java Program to solve the given problem.

The Denver Urban Sports Technicians (DUST) rent and sell recreational equipment including canoes, bikes, windsurfers, and trailers. The accountant for DUST requires a monthly supplier report. A number of suppliers are used and each sells equipment to DUST on a credit basis and charges DUST interest on the final monthly balance owed to the supplier. The transactions with each supplier are tracked over the month on a Supplier Transaction Sheet. The Supplier Transaction Sheet first lists the month the transactions occurred. Then for each supplier the Transaction Sheet lists the supplier name, the balance forward (balance owed to supplier for previous purchases) and the monthly interest rate. The supplier 's entry is followed by all the transactions related to the supplier for that month. Each transaction includes the transaction number, type and amount. DUST requires a monthly report to show all the information seen on the Supplier Transaction Sheet. Additionally at the end of each transaction record the report must display the current balance. And after each supplier 's last transaction the report must display the amount of monthly; interest due and the ending balance owed to the supplier. Also after all suppliers are processed a report summary must show the overall balance, the average purchases per supplier for the month, the total monthly payments, the highest supplier final balance and the name of the supplier owed this balance. In the case of multiple instances of the highest only report the first instance. All numeric values listed in the summary ar

Explanation / Answer

Transaction.java

public class Transaction {

private int tranNumber;

private char tranType;

private double tranAmount;

  

   public Transaction(int num,char type,double amount)

   {

       tranNumber=num;

       tranType=type;

       tranAmount=amount;

   }

  

   public int getTranNumber() {

       return tranNumber;

   }

   public void setTranNumber(int tranNumber) {

       this.tranNumber = tranNumber;

   }

   public char getTranType() {

       return tranType;

   }

   public void setTranType(char tranType) {

       this.tranType = tranType;

   }

   public double getTranAmount() {

       return tranAmount;

   }

   public void setTranAmount(double tranAmount) {

       this.tranAmount = tranAmount;

   }

}

Supplier.java

import java.util.ArrayList;

public class Supplier {

   private String name;

private double balanceForward;

private double interestRate;

   private ArrayList<Transaction> trans;

   public Supplier() {

       trans = new ArrayList<Transaction>();

   }

   public Supplier(String sName, double bal, double intr) {

       name = sName;

       balanceForward = bal;

       interestRate = intr;

       trans = new ArrayList<Transaction>();

   }

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this.name = name;

   }

   public double getBalanceForward() {

       return balanceForward;

   }

   public void setBalanceForward(double balanceForward) {

       this.balanceForward = balanceForward;

   }

   public double getInterestRate() {

       return interestRate;

   }

   public void setInterestRate(double interestRate) {

       this.interestRate = interestRate;

   }

   public ArrayList<Transaction> getTrans() {

       return trans;

   }

   public void setTrans(ArrayList<Transaction> trans) {

       this.trans = trans;

   }

   public void addTransaction(Transaction t) {

       trans.add(t);

   }

   public double getCurrentBalance() {

       double currentBalance = balanceForward;

       for (Transaction t : trans) {

           if (t.getTranType() == 'P') {

               currentBalance -= t.getTranAmount();

           } else if (t.getTranType() == 'B') {

               currentBalance += t.getTranAmount();

           }

       }

       return currentBalance;

   }

   public double getMonthlyInterest() {

       double current = getCurrentBalance();

       return current * interestRate / 100;

   }

   public double getEndingBalance() {

       double endingBalance = getCurrentBalance() + getMonthlyInterest();

       return endingBalance;

   }

   public double getAllPurchases() {

       double totalPurchase = 0;

       for (Transaction t : trans) {

           if (t.getTranType() == 'P')

               totalPurchase += t.getTranAmount();

       }

       return totalPurchase;

   }

   public double getAllPayments() {

       double payments = 0;

       for (Transaction t : trans) {

           if (t.getTranType() == 'P') {

               payments += t.getTranAmount();

           }

       }

       return payments;

   }

}

SupplierTranSheet.java

import java.util.ArrayList;

public class SupplierTranSheet {

   private String month;

   private ArrayList<Supplier> suppliers;

   public SupplierTranSheet(String month) {

       this.month = month;

       suppliers = new ArrayList<Supplier>();

   }

   public void addSupplier(Supplier s) {

       suppliers.add(s);

   }

  

   public void reportSummary()

   {

       System.out.println("Month Summary for month:"+month);

       System.out.println("Overall Balance: "+getOverallBalance());

       System.out.println("Average purchase per supplier for the month: "+getAveragePurchasePerSupplier());

       System.out.println("Total Payment: "+getTotalPayments());

       System.out.println("Supplier with highest final balance: "+getHighestBalanceSupplier().getName()

               +" and balance is: "+getHighestBalanceSupplier().getEndingBalance());

   }

// method to calculate overall balance by adding the ending balance of all

// suppliers

   public double getOverallBalance() {

       double overallBalance = 0;

       for (Supplier s : suppliers) {

           overallBalance += s.getEndingBalance();

       }

       return overallBalance;

   }

// method to calculate total payments made to all suppliers in the month

   public double getTotalPayments() {

       double totalPayments = 0;

       for (Supplier s : suppliers) {

           totalPayments += s.getAllPayments();

       }

       return totalPayments;

   }

// method to calculate average purchase per supplier for the month

   public double getAveragePurchasePerSupplier() {

       double totalPurchase = 0;

       for (Supplier s : suppliers) {

           totalPurchase += s.getAllPayments();

       }

       return totalPurchase / suppliers.size();

   }

// method to find the supplier with highest final balance

   public Supplier getHighestBalanceSupplier() {

       Supplier min = suppliers.get(0);

       for (Supplier s : suppliers) {

           if (s.getEndingBalance() > min.getEndingBalance()) {

               min = s;

           }

       }

       return min;

   }

}

Main.java

import java.io.*;

public class Main {

   public static void main(String[] args) throws IOException {

       InputStreamReader ir = new InputStreamReader(System.in);

       BufferedReader br = new BufferedReader(ir);

       System.out.println("Enter the month for Supplier Transaction sheet");

       String month = br.readLine();

       // creating a supplier transaction sheet for a given month

       SupplierTranSheet sheet = new SupplierTranSheet(month);

       while (true) {

           System.out.println("Enter the supplier name");

           String name = br.readLine();

           if (name.equalsIgnoreCase("done")) {

               break;

           }

           System.out.println("Enter the supplier's balance forward");

           double balance = Double.parseDouble(br.readLine());

           System.out.println("Enter the supplier's monthly interest rate");

           double rate = Double.parseDouble(br.readLine());

           Supplier s=new Supplier(name,balance,rate);

          

           while(true)

           {

               System.out.println("Enter the transaction number");

               int num=Integer.parseInt(br.readLine());

               if(num==0)

               {

                   break;

               }

               System.out.println("Enter the transaction type");

               char type=(char) br.read();

               br.readLine();

               System.out.println("Enter the transaction amount");

               double amount=Double.parseDouble(br.readLine());

               Transaction t=new Transaction(num,type,amount);

               s.addTransaction(t);

               System.out.println("Current balance after the transaction:"+s.getCurrentBalance());

           }

           System.out.println("Monthly Interest:"+s.getMonthlyInterest());

           System.out.println("Ending Balance:"+s.getEndingBalance());

           sheet.addSupplier(s);

       }

       //printing the report summary for the month

       sheet.reportSummary();

   }

}

output:

Enter the month for Supplier Transaction sheet

January

Enter the supplier name

Alpha Adventures

Enter the supplier's balance forward

3500.50

Enter the supplier's monthly interest rate

3.00

Enter the transaction number

21

Enter the transaction type

B

Enter the transaction amount

904.75

Current balance after the transaction:4405.25

Enter the transaction number

22

Enter the transaction type

P

Enter the transaction amount

1500.75

Current balance after the transaction:2904.5

Enter the transaction number

0

Monthly Interest:87.135

Ending Balance:2991.635

Enter the supplier name

Mike's Motor Bikes

Enter the supplier's balance forward

1500.20

Enter the supplier's monthly interest rate

3.50

Enter the transaction number

31

Enter the transaction type

B

Enter the transaction amount

102.88

Current balance after the transaction:1603.08

Enter the transaction number

32

Enter the transaction type

B

Enter the transaction amount

500.88

Current balance after the transaction:2103.96

Enter the transaction number

33

Enter the transaction type

B

Enter the transaction amount

2400.88

Current balance after the transaction:4504.84

Enter the transaction number

34

Enter the transaction type

P

Enter the transaction amount

1600.88

Current balance after the transaction:2903.96

Enter the transaction number

0

Monthly Interest:101.63860000000001

Ending Balance:3005.5986000000003

Enter the supplier name

Steph's Sails

Enter the supplier's balance forward

2600.00

Enter the supplier's monthly interest rate

5.00

Enter the transaction number

51

Enter the transaction type

B

Enter the transaction amount

1301.00

Current balance after the transaction:3901.0

Enter the transaction number

52

Enter the transaction type

P

Enter the transaction amount

1300.00

Current balance after the transaction:2601.0

Enter the transaction number

53

Enter the transaction type

P

Enter the transaction amount

1300.00

Current balance after the transaction:1301.0

Enter the transaction number

0

Monthly Interest:65.05

Ending Balance:1366.05

Enter the supplier name

Done

Month Summary for month:January

Overall Balance: 7363.283600000001

Average purchase per supplier for the month: 1900.5433333333333

Total Payment: 5701.63

Supplier with highest final balance: Mike's Motor Bikes and balance is: 3005.5986000000003

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote