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

Can I get the autolab instructions and the part 4 separately AutoLab Instruction

ID: 3721092 • Letter: C

Question

Can I get the autolab instructions and the part 4 separately

AutoLab Instructions In a class named "Lab3" write a public static method named "computeProfit" that takes three parameters and returns a double. The first parameter is a HashMap representing the selling price of each item in our store that we have been using throughout this lab. The second parameter is also a HashMap but this one represent our cost for us to purchase each type of item for our inventory. The third parameter is an ArrayListrepresenting all the orders that have been made in a day. This is an ArrayList where each element is a HashMap representing a customer's cart in the same format as the previous part. This method computes and returns our total profit for this day. Note that the profit of selling an item is the cost to the customer (prices in the first parameter) minus our cost to purchase the item for our inventory (second parameter). In all computation, use the following prices. Selling prices: (eggs 1.79, orange juice-2.5, yogurt-1.99, bread-2.49, butter-2.39, peppers-1.49, chips-2.95, chocolate chips-2.39 popcorn-1.99, tomato sauce-0.99, frozen pizza-5.49, milk 2.09, bananas-0.49, hot dog-1.29, relish-0.99, frozen dinner-2.5, cereal-3.25, tuna fish-0.99, coffee-2.0, pasta-0.99, strawberries-3.5, apples- 1.29, sugar-1.99, ketchup 2.89) Purchase prices: eggs-1.2, orange juice-1.0, yogurt=1.0, bread-1. 1 5, butter= 1 .95, peppers-0.99, chips-0.9, chocolate chips-1.79 popcorn-0.99, tomato sauce-04, frozen pizza-2.6, milk= 1.89, bananas-0.39, hot dog-0.79, relish-0.49, frozen dinner= 1.5, cereal= 1.55 tuna fish-0.49, coffee 0.6, pasta-0.5, strawberries-1.99, apples-0.99, sugar-1.5, ketchup 0.98)

Explanation / Answer

import java.util.ArrayList;

import java.util.HashMap;

public class Lab3 {

public static Double computeProfit(HashMap<String, Double> sellinPrice,

HashMap<String, Double> costPrice,

ArrayList<HashMap<String, Integer>> orderList) {

double profit=0.0;

for (HashMap<String, Integer> map : orderList) {

for(String key: map.keySet()) {

profit+=(sellinPrice.get(key)-costPrice.get(key))*map.get(key);

}

}

return profit;

}

public static void main(String[] args) {

HashMap<String, Double> sellingPrice=new HashMap<>();

sellingPrice.put("eggs", 1.79);

sellingPrice.put("orange juice", 2.5);

sellingPrice.put("yogurt", 1.99);

sellingPrice.put("bread", 1.99);

sellingPrice.put("butter", 2.39);

sellingPrice.put("peppers", 1.49);

sellingPrice.put("chips", 2.95);

sellingPrice.put("chocolate chips", 2.39);

sellingPrice.put("popcorn", 1.99);

sellingPrice.put("tomato sauce", .99);

sellingPrice.put("frozen pizza", 5.49);

sellingPrice.put("milk", 2.09);

sellingPrice.put("bananas", 0.49);

sellingPrice.put("hot dog", 1.29);

sellingPrice.put("relish", .99);

sellingPrice.put("frozen dinner", 2.5);

sellingPrice.put("cereal", 3.25);

sellingPrice.put("tuna fish", .99);

sellingPrice.put("cofee", 2.0);

sellingPrice.put("pasta", .99);

sellingPrice.put("strawberries", 3.5);

sellingPrice.put("apples", 1.29);

sellingPrice.put("sugar", 1.99);

sellingPrice.put("ketchup", 2.89);

HashMap<String, Double> costPrice=new HashMap<>();

costPrice.put("eggs", 1.2);

costPrice.put("orange juice", 1.0);

costPrice.put("yogurt", 1.0);

costPrice.put("bread", 1.15);

costPrice.put("butter", 1.95);

costPrice.put("peppers", 0.99);

costPrice.put("chips", 0.9);

costPrice.put("chocolate chips", 1.79);

costPrice.put("popcorn", 0.99);

costPrice.put("tomato sauce", .4);

costPrice.put("frozen pizza", 2.6);

costPrice.put("milk", 1.89);

costPrice.put("bananas", 0.39);

costPrice.put("hot dog", .79);

costPrice.put("relish", .49);

costPrice.put("frozen dinner", 1.5);

costPrice.put("cereal", 1.55);

costPrice.put("tuna fish", .49);

costPrice.put("cofee", 0.6);

costPrice.put("pasta", 0.5);

costPrice.put("strawberries", 1.99);

costPrice.put("apples", 0.99);

costPrice.put("sugar", 1.5);

costPrice.put("ketchup", 0.89);

ArrayList<HashMap<String, Integer>> allOrders=new ArrayList<>();

HashMap<String, Integer> cart0=new HashMap<>();

cart0.put("cereal", 4);

cart0.put("relish", 4);

allOrders.add(cart0);

HashMap<String, Integer> cart1=new HashMap<>();

cart1.put("chocolate chips", 3);

cart1.put("apples", 5);

allOrders.add(cart1);

HashMap<String, Integer> cart2=new HashMap<>();

cart2.put("chocolate chips", 2);

cart2.put("frozen pizza", 5);

allOrders.add(cart2);

HashMap<String, Integer> cart3=new HashMap<>();

cart3.put("butter", 2);

cart3.put("cereal", 3);

cart3.put("tuna fish", 4);

cart3.put("bananas", 4);

allOrders.add(cart3);

System.out.println(Lab3.computeProfit(sellingPrice, costPrice, allOrders));

}

}

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