Ask Question
5 June, 03:06

Suppose you have 5 1/2 gallons of milk and want to store them in milk jars that can hold up to 0.75 gallons each. You want to know ahead of time how many completely filled jars you will have. The following program has been written for that purpose. What is wrong with it? Why? How can you fix it? public class MilkJarCalculator{ public static void main (String[] args) { double milk = 5.5; / / gallons double jarCapacity = 0.75; / / gallons int completelyFilledJars = milk / jarCapacity; System. out. println (completelyFilledJars); }}

+2
Answers (1)
  1. 5 June, 06:21
    0
    public class MilkJarCalculator

    {

    public static void main (String[] args)

    {

    double milk = 5.5; / / gallons

    double jarCapacity = 0.75; / / gallons

    //apply the cast here

    int completelyFilledJars = (int) (milk / jarCapacity);

    System. out. println (completelyFilledJars);

    }

    }

    Explanation:

    public class MilkJarCalculator

    {

    public static void main (String[] args)

    {

    double milk = 5.5; / / gallons

    double jarCapacity = 0.75; / / gallons

    //apply the cast here

    int completelyFilledJars = (int) (milk / jarCapacity);

    System. out. println (completelyFilledJars);

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Suppose you have 5 1/2 gallons of milk and want to store them in milk jars that can hold up to 0.75 gallons each. You want to know ahead of ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers