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

A can of coffee holds 0.5 kg of coffee and sells for $10.00. The cost of the can

ID: 3664719 • Letter: A

Question

A can of coffee holds 0.5 kg of coffee and sells for $10.00. The cost of the can itself is $0.30. The packaging company buys coffee by the 50 lb sack at $200.00 each if there is no discount. If more than 10 sacks of coffee are purchased, each sack is discounted by 8%. If more than 50 cans are used, the price each drops from $0.30 to $0.26.

Write a program that asks the user to enter the number of bags of coffee purchased, and prints out the

• number of full cans of coffee that can be created and sold

• the amount of coffee that is wasted, if any (this is coffee that is left over after cans have been filled) and its cost

• the profit from the sale of all full cans (total sales - cost of cans - cost of any coffee not used)

*Create the program and turn it in by submitting ONLY the .java code.

Explanation / Answer

import java.util.*;

class cofee
{
   public static void main(String args[])
   {
       double disbagcost=0,totsalecost, totpurcost,nocans;

       System.out.println("Enter the number of bags of Cofee

Purchased");

       Scanner scan=new Scanner(System.in);

       double n=scan.nextDouble();

       if (n>10)
           disbagcost = (200*8/100) *n;
      
       nocans=(50/.5)*n;
       System.out.println("Enter total cans sold");
       int n1=scan.nextInt();


       System.out.println("Number of cans created =" +

nocans);
       totpurcost=n1*((200/50)+0.30);
       totsalecost= n1*10;

       System.out.println("amount of cofee wasted ="+(nocans

- n1));      
       System.out.println("Profit=" + (totsalecost - totpurcost));  
   }
}