in a java program. Imagine that you own a flower store and you need to display a menu of all the item categories, items and prices you sell for your customers.  Display the prices for each product and category. The flowers are {"Rose", "Carnation", "Tulips", "Sunflowers"}, the price in order are {1.15, 1.5, 2.5, 2.75} the second category is vase sizes, {"Small", "Medium", "Large", "XLarge"}, the prices in order are {1.25, 2.5, 3.75, 4.5}. The last category is add ons, {"Teddy Bear" , "note", "ballon", "choclates"}. The prices are in order {10.0, 2.5, 5.75, 8.75} The list of products and the list of prices should be stores in 2 separate arrays. Create a method "display" that accepts 2 arrays as parameters and displays the product and the prices in receipt form. Create another method "sum" that displays the total for each category.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

in a java program. Imagine that you own a flower store and you need to display a menu of all the item categories, items and prices you sell for your customers.  Display the prices for each product and category. The flowers are {"Rose", "Carnation", "Tulips", "Sunflowers"}, the price in order are {1.15, 1.5, 2.5, 2.75}

the second category is vase sizes, {"Small", "Medium", "Large", "XLarge"}, the prices in order are {1.25, 2.5, 3.75, 4.5}.

The last category is add ons, {"Teddy Bear" , "note", "ballon", "choclates"}.

The prices are in order {10.0, 2.5, 5.75, 8.75}

The list of products and the list of prices should be stores in 2 separate arrays. Create a method "display" that accepts 2 arrays as parameters and displays the product and the prices in receipt form. Create another method "sum" that displays the total for each category.

 
Description
Imagine that you own your own retail store and you need to display a menu of all the item categories, items and prices you sell for your
customers. Come up with any 3 or more categories that you would sell in your store. Come up with any 4 or more products for each
category. Display the prices for each product and category. The list of products and the list of prices should be stores in 2 separate
arrays. Create a method "display" that accepts 2 arrays as parameters and displays the product and the prices in receipt form. Create
another method "sum" that displays the total for each category.
Below is an example output for a Bagel shop selling bagels, bagel toppings and coffee. (Do NOT select bagels or coffe for your product
for your program assignment.) Each category has a list of products. For example, there are 4 bagel types, 4 bagel toppings, etc.
Welcome to Rose's Bakery Shop
Bagels
White $1.25
Whole Wheat $1.5
Onion $1.5
Sesame $1.75
Bagels Total $6.0
Bagel Toppings
Cream Cheese $0.5
Butter $0.25
Peach Jelly $0.75
Blueberry Jam $0.75
Bagel Toppings Total $2.25
Be creative, select any product categories and any associated products you find interesting or something you may have purchased
recently. Display the menu in any format. Optionally, include a subtotal, calculate the total tax and the total after taxes.
Submission Instructions
Transcribed Image Text:Description Imagine that you own your own retail store and you need to display a menu of all the item categories, items and prices you sell for your customers. Come up with any 3 or more categories that you would sell in your store. Come up with any 4 or more products for each category. Display the prices for each product and category. The list of products and the list of prices should be stores in 2 separate arrays. Create a method "display" that accepts 2 arrays as parameters and displays the product and the prices in receipt form. Create another method "sum" that displays the total for each category. Below is an example output for a Bagel shop selling bagels, bagel toppings and coffee. (Do NOT select bagels or coffe for your product for your program assignment.) Each category has a list of products. For example, there are 4 bagel types, 4 bagel toppings, etc. Welcome to Rose's Bakery Shop Bagels White $1.25 Whole Wheat $1.5 Onion $1.5 Sesame $1.75 Bagels Total $6.0 Bagel Toppings Cream Cheese $0.5 Butter $0.25 Peach Jelly $0.75 Blueberry Jam $0.75 Bagel Toppings Total $2.25 Be creative, select any product categories and any associated products you find interesting or something you may have purchased recently. Display the menu in any format. Optionally, include a subtotal, calculate the total tax and the total after taxes. Submission Instructions
Expert Solution
Step 1

I have implemented the given requirement as per the specification. The code is as follows:

public class Retail {
   
    public static void main(String[] args) {
        String[] flowers = { "Rose", "Carnation", "Tulips", "Sunflowers" };
        double[] priceFlowers = { 1.15, 1.5, 2.5, 2.75 };
        String[] sizes = { "Small", "Medium", "Large", "XLarge" };
        double[] priceSizes = { 1.25, 2.5, 3.75, 4.5 };
        String[] addOns = { "Teddy Bear" , "note", "ballon", "choclates" };
        double[] priceAddOns = { 10.0, 2.5, 5.75, 8.75 };
        double sumPrices = 0;

        System.out.println("\nFlowers");
        System.out.println("-------");
        display(flowers, priceFlowers);
        sumPrices = sum(priceFlowers);
        System.out.printf("\nFlowers Total $%.2f" , sumPrices);

        System.out.println("\n\nVase Sizes");
        System.out.println("----------");
        display(sizes, priceSizes);
        sumPrices = sum(priceSizes);
        System.out.printf("\nVase Sizes Total $%.2f" , sumPrices);

        System.out.println("\n\nAdd Ons");
        System.out.println("-------");
        display(addOns, priceAddOns);
        sumPrices = sum(priceAddOns);
        System.out.printf("\nAdd Ons Total $%.2f" , sumPrices);
    }

    private static double sum(double[] prices) {
        double sum = 0.0;
        for (int i = 0; i < prices.length; i++) {
            sum = sum + prices[i];
        }
        return sum;
    }

    private static void display(String[] category, double[] prices) {
        for (int i = 0; i < prices.length; i++) {
            System.out.println(category[i] + " $" + prices[i]);
        }
    }
}
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY