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 variable can be changed when using the WEEKDAY function
gregori [183]

Answer:

This brainly page should be able to help, make sure to thank them if it's correct

<em><u>brainly.com/question/15076370</u></em>

<em><u /></em>

3 0
3 years ago
____ are small programs stored on the hard drive that tell the computer how to communicate with a specific hardware device such
Luba_88 [7]
Device drivers........
5 0
3 years ago
You do not need to remove the lead weights inside tires before recycling them. A) TrueB) False
mel-nik [20]

Answer:

b you need to my dad is a car repair man and so am i

Explanation:

5 0
3 years ago
What is the definition of a nested function?
ExtremeBDS [4]

Answer:

A function that is defined within another function.

6 0
3 years ago
The doubling of the power of microprocessor technology while the costs of its production decreases by half is called ______ Law.
amm1812

Answer:

<em>The doubling of the power of microprocessor technology while the costs of its production decreases by half is called Moore's Law.</em>

Explanation:

The Moore's Law was a law derived from a projection on historical trend of the number of transistors in integrated circuits rather than a statement based on laws of Physics. This law stated originally that the number of transistors in an integrated circuit doubles whereas production costs halves due to gain in manufacturing and design experiences every two years. This empirical law was formulated in 1.965.

Microprocessors are IC-based.

The complete answer is: <em>The doubling of the power of microprocessor technology while the costs of its production decreases by half is called Moore's Law.</em>

8 0
3 years ago
Other questions:
  • Which loan type requires you to make loan payments while you’re attending school?
    10·1 answer
  • Suppose a computer has 16-bit instructions. The instruction set consists of 32 different operations. All instructions have an op
    6·1 answer
  • Try making a character (string) variable and a logical variable . Try creating a variable with a "missing" value NA. You can cal
    11·1 answer
  • Presentation software is the best file type for writing a research paper. <br> True <br> False
    10·1 answer
  • What is metrical task system algorithm?? and can we use that in online shopping project??
    11·1 answer
  • What are two software tools for bank account reconciliation?
    8·2 answers
  • The output for the following code will be: Pasta (1 mark)
    6·1 answer
  • The purpose of a good web page design is to make it
    9·2 answers
  • Which is a monthly cost associated with renting a house?
    11·2 answers
  • You want to add a caption to a table. which tab contains this option?.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!