I am practicing out of a book, self study. It is blowing my mind. If someone could help me ?
How do I subtract the amount of the first, second and third bag as well as collect the total number of bag?
The project asks these criteria > Assignment details The company sells coffee only in 2 pound bags. The price for each bags is 5.50. When a customer places an order, they are shipped the coffee in boxe. The boxes come in three sizes. Large(Contains 20 bags, medium(contains 10 bags, and small(contains 5 bags).
The cost of a large box is $1.80 medium $1.00 small $0.60 The order is shipped in the least expensive manner, for examples. the fule for packing is to fill the large and medium boxes completely. that is, the box is fuly packed. Only the small boxes can have empty spaces. but that would not leave the third box fully packed. Develop a program that computes the total cost of an order. Display the following format:
Number of bags ordered: 52 - $ 286.00
Boxes used 2 Large - 3.60 1 medium - 1.00 1 small - 0.60
Your total cost is: $291.20
sample code
import javax.swing.*;
import java.lang.*;
import java.text.DecimalFormat;
import java.util.*;
import java.io.*;
import java.math.*;
public class CoffeeBags {
public static void main(String [] args) throws IOException
{
DecimalFormat df = new DecimalFormat ("#,##0.00");
BufferedReader bufReader = new BufferedReader(new InputStreamReader(System.in));
int numberOfBags;
int largeBags = 2;
int mediumBags = 1;
int smallBags = 1;
double costOfLargeBags = 3.60;
double costOfMediumBags = 1.00;
double costOfSmallBags = 0.60;
double costPerBag = 5.50;
double totalCost;
double totalCostWithBags;
System.out.print("Enter number of bags to order: ");
String numberOfBagsStr = bufReader.readLine();
numberOfBags = Integer.parseInt(numberOfBagsStr);
totalCost = numberOfBags * costPerBag;
System.out.println("Number of bags ordered: " + numberOfBags + " - $" + df.format(totalCost));
System.out.println("Boxes used:");
System.out.println(" " + largeBags + " Large - $" + df.format(costOfLargeBags));
System.out.println(" " + mediumBags + " Medium - $" + df.format(costOfMediumBags));
System.out.println(" " + smallBags + " Small - $" + df.format(costOfSmallBags));
//System.out.print("Your total cost is: $ " + (totalCostWithBags));
//String numberOfUnitsStr = bufReader.readLine();
//numberOfUnits = Integer.parseInt(numberOfUnitsStr);
System.out.println("\nPress any key to continue. . .");
System.exit(0);
}
}