Answer to Question #270182 in Java | JSP | JSF for User 12345

Question #270182

write a program that implements computerized maintenance of your 

monthly expenditure record keeping. You have to build two classes ExpenseItem,  ExpenseLedger

The class ExpenseLedger will record all expenses you make. You record an expense by giving it a serial number, a description (that tells what it is about) and money you spent on this item. So you need to create a class ExpenseItem with serial, description and amount. Provide constructors, 

getters & setters & toString for this class. Now in ExpenseLedger class you need to build a collection that will hold instance of ExpenseItem. Provide following methods in ExpenseLedger 

1. int removeSmallExpenses(double amt):This method will find expense items that are smaller or equal to amount amt and then remove these items from list. Note that multiple items can be smaller than this value and thus each of these should be removed. Also this method should return number of items removed. 

2. Override toString method to print ledger in well formatted form


1
Expert's answer
2021-11-23T05:18:15-0500
import java.util.*;  
public class Main
{
	public static void main(String[] args) {
	}
}




class ExpenseItem{
    private int serialnum;
    private String description;
    private double amount;
    
    public ExpenseItem(){
        
    }


    public ExpenseItem(int serialnum, String description, double amount) {
        this.serialnum = serialnum;
        this.description = description;
        this.amount = amount;
    }
    


    public int getSerialnum() {
        return serialnum;
    }


    public void setSerialnum(int serialnum) {
        this.serialnum = serialnum;
    }


    public String getDescription() {
        return description;
    }


    public void setDescription(String description) {
        this.description = description;
    }


    public double getAmount() {
        return amount;
    }


    public void setAmount(double amount) {
        this.amount = amount;
    }


    @Override
    public String toString() {
        return "ExpenseItem{" + "serialnum=" + serialnum + ", description=" + description + ", amount=" + amount + '}';
    }
    
}




class ExpenseLedger{
    ArrayList<ExpenseItem> l=new ArrayList<ExpenseItem>();
    public ExpenseLedger(){
        
    }
    int removeSmallExpenses(double amt){
        //
    }
     @Override
    public String toString() {
        return "ExpenseItem{" + "serialnum=" + l.serialnum + ", description=" + l.description + ", amount=" + l.amount + '}';
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS