write a program that implements computerized maintenance of your
monthly expenditure record keeping. You will 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) & 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. void addExpense(description, amount): You should be able to figure out the serial of expense yourself. This method will create an expense item and add it to ledger
import java.util.*;
public class ExpenseItem{
int ser=input.nextInt();
String D=input.next();
int amt=input.next();
void totalExpenditure(){
System.out.println("Enter the total number of items recorded in the ledger: ");
double total=input.nextDouble();
System.out.println("Total number of items recorded are: "+total);
}
static void sumExpense(){
System.out.println("Input the name of item and the price of the item: ");
String item=input.next();
int AMT=input.nextInt();
}
static void removeSmallExpenses(){
System.out.println("Input the details of item to be removed: ");
double amt=input.nextDouble();
}
public static void main(String[] args) {
class classObj = ledger.class();
Constructor[] constructor = classObj.getConstructors();
String string = constructor[0].toString();
System.out.println("Constructor : " + string);
totalExpenditure();
removeSmallExpenses();
sumExpense();
}
public class ledger{
public ledger(Object... obj)
{
int array[5]={"cups","plates","carrots","spoons","onions"}
for(int i=0;i<5;i++){
array[i];
}
}
}
}
Comments
Leave a comment