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]
4 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]4 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
marion is an iot developer working for a large organization. why does his supervisor want him to stay informed about the network
Andreyy89

As these upgrades advance, 5G availability is anticipated to rise quickly.Compared to current LTE networks, 5G is expected to be ten times quicker. Since India's 5G launch won't even start until the second half of 2022,

<h3 /><h3>How soon will 5G be a reality?</h3>
  • The 3GPP has already decided to include 5Gi in Release 17, which is scheduled to be released in March or June of this year. Since India's 5G launch won't even start until the second half of 2022, this will allow gear to integrate 5Gi capabilities as early as 2023.
  • 5G networks are quickly paving the way for the deployment of autonomous systems like reconnaissance drones and support the strengthening of the communications infrastructure, including systems used by first responders. They do this by combining the massive IoT edge computing capability with lower data latency and an improved mobile broadband experience.
  • Compared to current LTE networks, 5G is expected to be ten times quicker. IoT devices will be able to converse and share data more quickly than before thanks to this improvement in speed.

To learn more about 5G networks refer to:

brainly.com/question/25520771

#SPJ1

5 0
1 year ago
Explain the difference between social engineering and reverse social engineering.
san4es73 [151]
Social Engineering is the art of eliciting sensitive information from people by tricking them. Like through phishing, fake emails that contain a virus and fake programs. They get your password or any other sensitive information by making you think the website/program is legit. That's why you should always make sure the new website/program you visited is safe.

Reverse Social Engineering is, on the other hand, where the initial attacker becomes attacked. Or the victim redirects the attacker to someone who can counter the attacker. E.g attackers call the front desk and ask for information X. Instead or giving him information X, front desk redirects the call to the security department. An example is where the attacker is fed false information. Law enforcement agencies often perform this attack.
5 0
3 years ago
How many voltage values can be represented with a 10-bit binary code?
viktelen [127]
Answer is D. 1024
8 bits is enough to represent 256 different numbers. 9 bits is enough to represent 512 numbers. 10 bits can represent 1024 numbers.
8 0
3 years ago
Select all statements that correctly describe the ramifications of important features supported by modern DBMS.
lara [203]

Answer:  

"Option b and Option d" is the correct option for this question.

Explanation:

In the database, datatype belongs to the information storage medium, which can hold a specific type of value. There are several data types, which is used in database like integer, character, series, floating-point and array numbers, and the rules, that give levels of security to information are known as a security constraints. It may be either developed as rules on integrity, mathematical formalism rules or schematic rules, and other choices were wrong which can be described as follows:

  • In option a, The asserts, which is in any exchange in a database, should only modify the information, that is effected in acceptable ways is called consistency, that's why it is wrong.
  • In option c, The validity and accuracy of the data in the database can not be ensured, that's why it is wrong.
3 0
3 years ago
Write 4 types of viruses , explain them briefly.
wariber [46]

I can help with two.

Web Scripting Virus, A sneaky virus that targets popular websites. What this virus does is overwrite code on a website and insert links that can install malicious software on your device. Web scripting viruses can steal your cookies and use the information to post on your behalf on the infected website.

FILE INFECTOR, targeting executable files (.exe), file infector viruses slow down programs and damage system files when a user runs them.

8 0
3 years ago
Other questions:
  • Which type of hypervisor does not run on an underlying operating system?
    13·1 answer
  • What makes a distributed denial of service attack "distributed"? It involves many ip addresses. It attacks multiple systems. It
    9·1 answer
  • You play guitar and keep two files on your computer. One file, called strings, lists the different brands of strings you keep on
    8·1 answer
  • Field names should NOT start with a(n) -<br> hyphen (-)<br> Oa<br> asterisk (*)<br> space()
    8·1 answer
  • You recently upgraded your computer and added an extra 512 MB of RAM. Consequently, you want to increase your swap space by addi
    10·1 answer
  • Which option on the Format tab is used to modify particular portions of the chart?
    12·1 answer
  • A letter of application should be written on:
    13·1 answer
  • _____moves the head to proper track
    13·2 answers
  • Circuit pruning occurs only before puberty.<br> O True<br> O False
    9·2 answers
  • Question 12 (5 points)
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!