1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Lelu [443]
3 years ago
8

You have been given the job of creating a new order processing system for the Yummy Fruit CompanyTM. The system reads pricing in

formation for the various delicious varieties of fruit stocked by YFC, and then processes invoices from customers, determining the total amount for each invoice based on the type and quantity of fruit for each line item in the invoice. The program input starts with the pricing information. Each fruit price (single quantity) is specified on a single line, with the fruit name followed by the price. You can assume that each fruit name is a single word consisting of alphabetic characters (A–Z and a–z). You can also assume that prices will have exactly two decimal places after the decimal point. Fruit names and prices are separated by a single space character. The list of fruit prices is terminated by a single line consisting of the text END_PRICES. After the fruit prices, there will be one or more invoices. Each invoice consists of a series of line items. A line item is a fruit name followed by an integer quantity, with the fruit name and quantity separated by a single space. You can assume that no line item will specify a fruit name that is not specified in the fruit prices. Each invoice is terminated by a line consisting of the text END_INVOICE. As a special case, if a line with the text QUIT appears instead of the beginning of an invoice, the program should exit immediately. The overall input will always be terminated by a QUIT line. (5 points)
Computers and Technology
1 answer:
Dmitriy789 [7]3 years ago
7 0

Answer:

Invoice.java

import java.util.*;

public class Invoice {

   static final String endPrices = "END_PRICES";

   static final String endInvoice = "END_INVOICE";

   static final String quit = "QUIT";

   public static void main(String... args) {

       Scanner sc = new Scanner(System.in);

<em>        //HashMap to store fruit name as key and price as value </em>

       Map<String, Float> fruits = new HashMap<>();

<em>        //Loop until input is not "END_PRICES" </em>

       while (true){

           String input = sc.next();

<em>            //Come out of loop if input is "END_PRICES" </em>

           if(input.equals(endPrices))

               break;

           float price = Float.parseFloat(sc.next());

<em>            //add fruit to hash map </em>

           fruits.put(input, price);

       }

<em>        //ArrayList to store total cost of each invoice </em>

       List<Float> totalList = new ArrayList<>();

       Float total = 0f;

<em>        //loop until input becomes "QUIT" </em>

       while (true){

           String input = sc.next();

<em>            //Break out of the loop if input is "QUIT" </em>

           if(input.equals(quit)){

               break;

           }

<em>            //Add total price of the invoice to array list and set total to "0f" to store total of next invoice </em>

           if(input.equals(endInvoice)){

               totalList.add(total);

               total = 0f;

               continue;

           }

           int quantity = sc.nextInt();

           total += (fruits.get(input)*quantity);

       }

<em>        //Iterate through all objects in the total Array List and print them </em>

       Iterator itr = totalList.iterator();

       while (itr.hasNext()){

           System.out.printf("Total: %.2f \n", itr.next());

       }

   }

}

You might be interested in
Because of the abundance of water on planet Earth, hydrogen gas (H2) is a candidate in the search for a replacement for petroleu
Dennis_Churaev [7]

The reason why plants are considered to be one step ahead in the utilization of hydrogen as an alternative fuel source is because; Plant cells possess water-splitting enzymes

<h3>What are splitting Enzymes?</h3>

Splitting Enzyme’s are like aldolases that catalyze the conversion of a molecule into two smaller molecules without the addition or removal of any atoms.

Now in plant biology, plants make use of he light-driven water-splitting/oxygen-evolving enzyme known as Photosystem II in photosynthesis to split water.

Read more about splitting enzymes at; brainly.com/question/14713715

3 0
2 years ago
Eureka! Is a telephone and Internet-based concierge service that specializes in obtaining things that are hard to find (e.g., Su
svetoff [14.1K]

Explanation:

Should the company separate its voice and data needs, using standard analog services for voice but finding some advanced digital transmission services for data ($40 per month for each voice line and $300 per month for a circuit with 1.5 Mbps for data)?

8 0
2 years ago
Why would a designer choose to use a static layout? Check all of the boxes that apply.
Dafna1 [17]

Answer:

Explanation:a & c

6 0
3 years ago
(True or False) All notes have a rest?
nikitadnepr [17]

Answer:

True i think i am not sure

Explanation:

7 0
3 years ago
Read 2 more answers
Software ............. the hardware what to display on the user's screen​
likoan [24]
A monitor? This displays on the users screen but I’m not sure if that’s what your asking good luck on finding the right answer.
7 0
2 years ago
Other questions:
  • (3.01 MC)
    11·1 answer
  • IT professionals recognize that successful systems must be user-oriented, and users need to be involved, formally or informally,
    11·1 answer
  • In a gear system, when you gain torque you lose what?
    11·1 answer
  • Careers in information technology deal with
    12·2 answers
  • The individual accountable for ensuring the day-to-day operation of the InfoSec program, accomplishing the objectives identified
    7·1 answer
  • Choose the type of error described.
    12·1 answer
  • How does a Cloud-first strategy approach a client's migration to the Cloud?
    11·1 answer
  • Which of the following scenarios describes an IT
    7·2 answers
  • Brook is designing a database that customers can use to find their ideal vacation spot. If they only want to see beach vacations
    15·2 answers
  • Keira is creating an app for her cross-country team. Users will input their race times and the output will be a graph showing th
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!