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
How are Action Buttons different than hyperlinks?
ipn [44]

Actions buttons are different than hyperlinks in many ways.

2)They are predefined shapes.

<u>Explanation:</u>

Action buttons are predefined shapes in the PowerPoint and can be used for moving between the slides of the presentation and for referring to the hyperlinks as well.

Action buttons have a predefined shape and that shape can be used to set the functionality of that particular button as a convention. Action buttons make up a strong presentation.

Action buttons can be invoked by clicking on them or just hovering over them and various sound effects can also be added on both the events to make the presentation more engaging and attractive.

8 0
3 years ago
Como realizar un cuadro comprativo?​
Kruka [31]
How to make a comparison chart?
3 0
3 years ago
What gonna happened if you put rice water in your hair
Nikitich [7]

Answer:

That does something?

Explanation:

(•_•)

<) )╯all the single ladies

/ \

(•_•)

\( (> all the single ladies

/ \

(•_•)

<) )╯oh oh oh

/ \

7 0
3 years ago
u arrive at an intersection with traffic lights that are not working because of a power outage. What do you do?
maxonik [38]
Go to o rilles or autozone
5 0
3 years ago
Steve wants to become a successful graphic design entrepreneur. Which entrepreneurial approach will help him succeed? A. working
xxMikexx [17]

Answer:

Option(D) is the correct answer to the given question .

Explanation:

The  main objective of graphic design entrepreneur is to design the animation such as company logos, booklets, product labeling ,etc .The graphic designers are also operated independently that is it designing the products for the business customers, marketing firms, newspapers ,public affairs firms and etc.

  • With the help of hiring designers for work  then the steve wants to be a good graphic design businessman and get success in life .
  • All the other option are not correct for the design for graphics that's why these are incorrect option .
5 0
3 years ago
Other questions:
  • Several steps are involved in creating a presentation. what is the last step in the process before preparing to presenting it?
    12·1 answer
  • Which of the following is an example of a wanted versus I need
    5·1 answer
  • If you omit the filename from a URL, the Apache web server displays a list of files and directories if the specified directory d
    15·1 answer
  • Example of hard ware that computers on a network can share are he operating and the web browser? True or false
    7·2 answers
  • Which tool do you think would be the most useful if you were designing a logo for a business?
    6·2 answers
  • A.
    11·1 answer
  • Using simplified language and numbers, using large font type with more spacing between questions, and having students record ans
    9·1 answer
  • Dash is a collection of sequentially arranged slides put together in the from of a file​
    8·1 answer
  • Wml script is used in? ​
    14·1 answer
  • The format that you will use on your works cited page when the entry is longer than one line is__________.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!