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
ivanzaharov [21]
3 years ago
13

Coding 5 - Classes The Item class is defined for you. See the bottom of the file to see how we will run the code. Define a class

ShoppingCart which supports the following functions: add_item(), get_total_price(), and print_summary(). Write code only where the three TODO's are. Below is the expected output: Added 2 Pizza(s) to Cart, at $13.12 each. Added 1 Soap(s) to Cart, at $2.25 each. Added 5 Cookie(s) to Cart, at $3.77 each.
Computers and Technology
1 answer:
ICE Princess25 [194]3 years ago
7 0

Answer:

Explanation:

The following is written in Java. It creates the ShoppingCart class as requested and implements the requested methods. A test class has been added to the main method and the output is highlighted in red down below.

import java.util.ArrayList;

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       ShoppingCart newCart = new ShoppingCart();

       newCart.add_item();

       newCart.add_item();

       newCart.add_item();

       newCart.print_summary();

   }

}

class ShoppingCart {

   Scanner in = new Scanner(System.in);

   ArrayList<String> items = new ArrayList<>();

   ArrayList<Integer> amount = new ArrayList<>();

   ArrayList<Double> cost = new ArrayList<>();

   public ShoppingCart() {

   }

   public void add_item() {

       System.out.println("Enter Item:");

       this.items.add(this.in.next());

       System.out.println("Enter Item Amount:");

       this.amount.add(this.in.nextInt());

       System.out.println("Enter Cost Per Item:");

       this.cost.add(this.in.nextDouble());

   }

   public void get_total_price() {

       double total = 0;

       for (double price: cost) {

           total += price;

       }

       System.out.println("Total Cost: $" + total);

   }

   public void print_summary() {

       for (int i = 0; i < items.size(); i++) {

           System.out.println(amount.get(i) + " " + items.get(i) + " at " + cost.get(i) + " each.");

       }

       get_total_price();

   }

}

You might be interested in
Xercise 1<br>1.<br>What is system? Explain the components of system in brief.​
noname [10]

Answer:

A system is a collection of elements or components that are organized for a common purpose. ... A computer system consists of hardware components that have been carefully chosen so that they work well together and software components or programs that run in the computer.

Explanation:

4 0
3 years ago
How can i become an ailen?
DIA [1.3K]
Go to a different state as a migrant and then your a alien
8 0
3 years ago
Read 2 more answers
Which of the following statements is true?
Lilit [14]

Answer:

Option A is the correct answer choice for the above question.

Explanation:

The computer system needs intercommunication which is done inside the processor to process the task given by the user. There are two types of model is used for intercommunication--

  1. Message passing and
  2. Shared memory

The difference between two is that message passing passes the message on two points at a single unit of time whereas shared memory simultaneous shares the multiple messages. That's why shared memory is faster than message passing.

  • Hence option A is the correct choice because it also refers to the above concept. While the other is not correct because--
  • Option B states that message passing is faster than shared memory which is wrong.  
  • Option C states that message passing is used for large data but shared memory is used for large data.
  • Option D states that shared memory is unavailable in some processor which is wrong.
3 0
3 years ago
Allison is preparing to modify a network access control list and add three firewall rules to her private cloud HR systems. She i
Yakvenalex [24]

C. Change management

Allison is preparing to modify a network access control list and add three firewall rules to her private cloud HR systems by following the Change management process.

What exactly is change management?

Change management is the process of developing and implementing effective change strategies in businesses and organizations.

Examining the reasons for change, implementing changes, and assisting people in adapting to these changes are all part of it. This could include reorganizing the workforce, implementing new technology, lowering costs, increasing profits, or a combination of these to achieve a specific goal.

To know more about Change management, visit: brainly.com/question/28096717

#SPJ4

4 0
1 year ago
On which side of the keyboard is the numeric keypad usually located
Rina8888 [55]

Numeric keypad. Alternatively referred to as the 10-key, number pad, numeric keyboard, numpad, or ten key, the numeric keypad is a 17-key keypad usually found on the far right side of a standard PC keyboard

6 0
3 years ago
Read 2 more answers
Other questions:
  • To display measurements on the ruler while changing column widths, hold down the ________ key while dragging the marker.
    13·1 answer
  • Write an algorithm to determine a students final grade and indicate whether it is passing or failing .the final grade is calcula
    12·1 answer
  • What is the best way to improve the following code fragment? if ((counter % 10) == 0) { System.out.println("Counter is divisible
    11·1 answer
  • 3. In 1989, the first handheld console was released by _____ and it was called ________.
    13·1 answer
  • HELP MY TABLET KEEPS ON REBOOTING I TRIED TO FACTORY RESET BUT IT KEEPS ON REBOOTING
    12·2 answers
  • Instructions
    13·1 answer
  • How can she change that value so it is reflected in the chart in her presentation?
    5·2 answers
  • What is the output for the following program?
    6·1 answer
  • As part of your regular system maintenance, you install the latest operating system updates on your Windows 10 computer. After s
    12·1 answer
  • Bluetooth is the popular name for the 802. 15 wireless networking standard, which is useful for creating small __________.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!