Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are multiple answers on chegg for this question but they all fal short - either missing sentinel, or calculate discount but do not calculate

There are multiple answers on chegg for this question but they all fal short - either missing sentinel, or calculate discount but do not calculate actual total or apply discount...

A pet shop wants to give a discount to its clients if they buy one or more pets and at least five other items. The discount is equal to 20 percent of the cost of the other items, but not the pets.

To solve the problem, implement a method:

public static void discount(double[] prices, boolean[] isPet, int nItems)

The method receives information about a particular sale. For the ith item, prices[i] is the price before any discount, and isPet[i] is true if the item is a pet.

Write a program that prompts a cashier via a method to enter each price and then a Y for a pet or N for another item. Use a price of -1 as a sentinel. Save the inputs in an array. Call the discount()method, and display the discount.

Must have: Good java style; JavaDoc comments and comments in the code.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

=+How might these stem from country and regional cultures?

Answered: 1 week ago