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
What does Al stand for?
prohojiy [21]
AI stands for Artificial Intelligence
5 0
3 years ago
When you take a multiple-choice test, you are relying on ________, a means of retrieving information out of your long-term memor
Karolina [17]

Answer:b)Recognition

Explanation: Recognition method is the technique which is based upon the similarity of the structure.It basically compares between the received format and the format of the reference on the basis of their structure.It is considered as a good method of the retrieving the image or format which is in storage. This usually results in opting the correct answer or option.

Therefore, the correct answer is option (b).

8 0
3 years ago
HELP PLEASE NOW ASAP BRAINLIEST
charle [14.2K]
<span>Josie lives in an area where there are frequent power cuts. She should use a UPS (Uninterruptible Power Supply). It protects against damage to a computer's hard drive (data) in case of a sudden shutdown.

Hope this helps!</span>
7 0
3 years ago
Read 2 more answers
LEARNING TASK 3 about: REAMING THE RIGID STEEL CONDUIT.
devlian [24]

Answer:

1.I have learned that my teacher is a good teacher

2.I have realized that my name is beautiful

Explanation:

thats right? hope it's help you heart me and please give brainlesst

3 0
2 years ago
Write a 5 – 7+ sentence paragraph about Thanksgiving that DOES NOT use the letter “t.”
Norma-Jean [14]

A period in all of our lives which is recognizing a major bond including family and friends. When summer concludes, a new season comes around bringing a cold, and chilly breeze which is fall. Fall is a special season because occurrences such as leaves falling from conifers, looking for a good pumpkin in the pumpkin field, or simply enjoying  your family and friends company. Drinking warm drinks such as coffee and baking cookies can help you embrace such an amazing season. When fall rolls around, Always be aware of nearby occurrences which can bring you joy during a cold season such as fall.

5 0
2 years ago
Other questions:
  • What does a graphic organizer do
    6·1 answer
  • Why are advanced features helpful when businesses use spreadsheets
    5·1 answer
  • If you see ________________________ in a cell, it means the column is not wide enough to display the cell content. Select one: a
    15·1 answer
  • What are two examples of management information systems?
    12·1 answer
  • When a person bullies someone using technology, it's called:
    9·2 answers
  • What is the cell reference for row 22 and column B? __________<br><br> In excel
    5·1 answer
  • To specify your preferred colors, fonts, and effects for a document, which of the following should be done?
    5·2 answers
  • Being a part of an organization or giving back to the community is which rewards of work factor?
    6·1 answer
  • What is the benefit of hosting a website on a personali
    6·1 answer
  • What does an arrow after a command indicate
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!