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

4. Housemate Helper Overvie This program allows a bunch of housemates to organiz

ID: 3739634 • Letter: 4

Question

4. Housemate Helper Overvie This program allows a bunch of housemates to organize the sharing of expenses and the maintaining of inventory. Any housemate can enter his name, an item he bought (by category, either: Food, Utility, or Toy) the quantity of the item and the total amount of money he spent. Then various queries can be made, about the quantity of items, about who owes who money, and so on, as detailed below Requirements You must 1) create a class named HousemateHelper, which will be described below, 2) create other classes as needed, which w be known by the top level class HousemateHelper, 3) write a simple console application (no graphics!) that uses the class HousemateHelper, with a few simple method calls, to create an interactive housemate helper In the following discussion by a Item-String we mean a string which takes on one of the following 3 val food" ty", or "toy". The class HousemateHelper, must have at least the following methods (it may have more methods): (a) The initializer takes no iputs. (b) addPurchase: Takes as input Name, Item, Quantity, Cost; where Name is the name of the person who bought the item, Item is an Item-String, Quantity is positive integer and Cost is a float. This information should be appropriately saved. (c) getInventory: Takes a string input which should be an em-string, and returns the quantity of that item currently possessed (d) useltem: Takes as input a string, and a positive integer k. The string should be an Item-String. The result is that k of the given item are removed from inventory (e) personValue: Takes a string as input, which should be one of the people who has purchased something. The method returns a float (positive, negative, or zero) which indicates how much that person is in owed. (f) equalize: Takes no inputs Indicates a scheme by which people can make pay- ments to equalize everything. The format output should be a list of tuples, where each tuple is of the form (A, B, x), where A and B are person names, and x is an mount of money that A should pay to B

Explanation / Answer

import java.util.*;

public class Main {

    /**

     * @param args the command line arguments

     */

    public static void main(String[] args) {

        //Variable Declarations

        String place;

        String[] roommates = new String[20];

        String[] bills = new String[20];

        int amount[] = new int[20];

        int numRoom = 0;

        int numBills = 0;

        int i = 0;

         

        Scanner input = new Scanner(System.in);

         

        System.out.println("Welcome to Roommate Bill Splitter! ");

         

        //Get Residence Name from User

        System.out.print("Please Enter Name of Place or Address: ");

        place = input.nextLine();

         

        //Get # of Roommates at Residence

        System.out.print("How Many Total People Reside at " + place + ": ");

        numRoom = input.nextInt();

         

        //Get Names of Roommates

        for(i = 0; i <= numRoom; i++){

            roommates[i] = input.nextLine();

            System.out.print("What is Person Number " + (i + 1) + "'s Name: ");

        }

         

        for(i = 0; i <= numRoom; i++){

            System.out.println(roommates[i]);

        }

         

        //Get # of Bills Split Between Roommates

        System.out.print("What is the Total Number of Bills to be Split at " + place + ": ");

        numBills = input.nextInt();

         

        //Get Names of Roommates

        for(i = 0; i <= numBills; i++){

            bills[i] = input.nextLine();

            System.out.print("Please List Bill Number " + (i + 1) + ": ");

        }

         

        for(i = 0; i <= numBills; i++){

            System.out.println(bills[i]);

        }

          

        //Get Amount of Each Bill

        for(i = 0; i <= numBills; i++){

            amount[i] = input.nextInt();

            System.out.print("What is the Total Amount of the " + (bills[i]) + "Bill: $");

        }

         

         for(i = 0; i <= numBills; i++){

            System.out.print(bills[i]);

            System.out.print(" ");

            System.out.println(amount[i]);

        }        

    }

     

}

The code would look something like this.

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