Question

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

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
The cost of 12 bagels is $7.20.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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);
    }
}

Add a comment
Know the answer?
Add Answer to:
A bagel shop charges 80 cents per bagel for orders of less than a half-dozen bagels...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT