Question

In: Computer Science

In Java): A vending machine serves chips, fruit, nuts, juice, water, and coffee. The machine owner...

In Java): A vending machine serves chips, fruit, nuts, juice, water, and coffee. The machine owner wants a daily report indicating what items sold that day. Given boolean values (true or false) indicating whether or not at least one of each item was sold (in the order chips, fruit, nuts, juice, water, and coffee), output a list for the owner. If all three snacks were sold, output "All-snacks" instead of individual snacks. Likewise, output "All-drinks" if appropriate. For coding simplicity, output a space after every item, including the last item.

Solutions

Expert Solution

/**
*
* problem
*
* A vending machine serves chips, fruit, nuts, juice, water, and
* coffee. The machine owner wants a daily report indicating what items
* sold that day. Given boolean values (true or false) indicating
* whether or not at least one of each item was sold (in the order
* chips, fruit, nuts, juice, water, and coffee), output a list for the
* owner. If all three snacks were sold, output "All-snacks" instead of
* individual snacks. Likewise, output "All-drinks" if appropriate. For
* coding simplicity, output a space after every item, including the
* last item.
*/

public class ItemsSold {
   public static void main(String arg[]) {
       boolean isChipsSold = true, isFruitSold = true, isNutsSold = false, isJuiceSold = false, isWaterSold = false,
               isCoffeeSold = false;
       boolean snacksSold = isChipsSold && isFruitSold && isNutsSold;
       boolean drinksSold = isJuiceSold && isWaterSold && isCoffeeSold;
       if (snacksSold) {
           System.out.println("All-snacks");
       } else {
           if (isChipsSold) {
               System.out.println("Chips sold");
           }

           if (isFruitSold) {
               System.out.println("Fruit sold");
           } if (isNutsSold) {
               System.out.println("Nuts sold");
           }
       }

       if (drinksSold) {
           System.out.println("All-drinks");
       } else {
           if (isJuiceSold) {
               System.out.println("Juice sold");
           }

           if (isWaterSold) {
               System.out.println("Water sold");
           } if (isCoffeeSold) {
               System.out.println("Coffee sold");
           }
       }
   }
}


Related Solutions

A vending machine serves chips, fruit, nuts, juice, water, and coffee. The machine owner wants a...
A vending machine serves chips, fruit, nuts, juice, water, and coffee. The machine owner wants a daily report indicating what items sold that day. Given boolean values (true or false) indicating whether or not at least one of each item was sold (in the order chips, fruit, nuts, juice, water, and coffee), output a list for the owner. If all three snacks were sold, output "All-snacks" instead of individual snacks. Likewise, output "All-drinks" if appropriate. For coding simplicity, output a...
Coding Java Vending machine Lab
Given two integers as user inputs that represent the number of drinks to buy and the number of bottles to restock, create a VendingMachine object that performs the following operations:Purchases input number of drinksRestocks input number of bottlesReports inventoryThe VendingMachine is found in VendingMachine.java. A VendingMachine's initial inventory is 20 drinks.Ex: If the input is:5 2the output is:Inventory: 17 bottles import java.util.Scanner; public class LabProgram {    public static void main(String[] args) {       Scanner scnr = new Scanner(System.in);              /* Type your code here. */            } }
A vending machine dispenses coffee. The average cup of coffee is supposed to contain 7.0 ounces....
A vending machine dispenses coffee. The average cup of coffee is supposed to contain 7.0 ounces. Eight cups of coffee from this machine show the average content to be 7.3 ounces with a standard deviation of 0.5 ounce. Using a 5% level of significance, test whether the machine has slipped out of adjustment and if the average amount of coffee per cup is different from 7 ounces. Determine the p-value and interpret the results
The amount of coffee dispensed by a drink vending machine is normally distributed with a mean...
The amount of coffee dispensed by a drink vending machine is normally distributed with a mean of 12.1 oz. What is the probability that a randomly selected cup of coffee has more than 12.8 oz? Assume that the standard deviation for all drink vending machines is 0.38
A manufacturer of coffee vending machines has designed a new, less expensive machine. The current machine...
A manufacturer of coffee vending machines has designed a new, less expensive machine. The current machine is known to dispense an average of 5 fl. oz., with a standard deviation of .2 fl. oz., into cups. When the new machine is tested using 15 cups, the mean and the standard deviation of the fills are found to be 5 fl. oz. and .213 fl. oz. Test H0: σ = .2 versus Ha: σ ≠ .2 at levels of significance .05...
A vending machine dispenses hot chocolate or coffee. Service time is 35 seconds per cup and...
A vending machine dispenses hot chocolate or coffee. Service time is 35 seconds per cup and is constant. Customers arrive at a mean rate of 66 per hour, and this rate is Poisson-distributed. a. Determine the average number of customers waiting in line. (Round your answer to 2 decimal places.) Average number of customer            b. Determine the average time customers spend in the system. (Do not round intermediate calculations. Round your answer to 2 decimal places.) Average time...
A vending machine dispenses hot chocolate or coffee. Service time is 35 seconds per cup and...
A vending machine dispenses hot chocolate or coffee. Service time is 35 seconds per cup and is constant. Customers arrive at a mean rate of 61 per hour, and this rate is Poisson-distributed. a. Determine the average number of customers waiting in line. (Round your answer to 2 decimal places.)    Average number of customer             b. Determine the average time customers spend in the system. (Do not round intermediate calculations. Round your answer to 2 decimal places.)   ...
Write a java console application,. It simulates the vending machine and ask two questions. When you...
Write a java console application,. It simulates the vending machine and ask two questions. When you run your code, it will do following: Computer output: What item you want? User input: Soda If user input is Soda Computer output: How many cans do you want? User input:            3 Computer output: Please pay $3.00. END The vending machine has 3 items for sale: Soda the price is $1.50/can. Computer should ask “How many cans do you want?” Chips, the price is $1.20/bag....
We titrate a juice ingridents are water, fructose, citric acid, and flavoring. I measure out 5mL of the juice and put it in a titrator machine.
  We titrate a juice ingridents are water, fructose, citric acid, and flavoring. I measure out 5mL of the juice and put it in a titrator machine. The known base is 0.1M NaOH, it takes 1.892mL to bring the pH up to 8.32. I know the ratio of citric acid to sodium hydoxride is 3:1. I forget how to include this part in my equation... So this is what I do .1M*.001892L/.005L= .03784M of citric acid.   Now I want to...
You are in the train station waiting for your train to arrive. You see a vending machine from where you can buy snacks and chips for $3.50.
  You are in the train station waiting for your train to arrive. You see a vending machine from where you can buy snacks and chips for $3.50. Posted on the machine is a sign saying: “Property of XYZ Vendsolutions Pty Ltd”. You insert the coins required into the machine and out comes a packet of chips. However, when you open the packet of chips, you find bits of plastic inside and you don’t want to eat the chips. You...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT