A bagel shop charges 80 cents per bagel for orders of less than a half-dozen bagels and 60 cents per bagel for orders of a half-dozen or more. Write a program that requests the number of bagels ordered and displays the total cost.
|
How many bagels are
ordered: 12 |

import java.util.Scanner;
public class BagelShop {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("How many bagels are ordered: ");
int n = in.nextInt();
double cost;
if (n < 12) {
cost = n * 0.8;
} else {
cost = n * 0.6;
}
System.out.printf("The cost of %d bagels is $%.2f.
", n, cost);
}
}

A bagel shop charges 80 cents per bagel for orders of less than a half-dozen bagels...