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
Which item can you add using the tag?
Svetllana [295]

Answer:

an image

Explanation:

good luck have a nice day

3 0
3 years ago
Read 2 more answers
What was Leonardo da Vinci an expert in
Ipatiy [6.2K]

Leonardo da Vinci was a very famous painter. I would assume that he is an expert in painting.

Hope this helped

5 0
3 years ago
Absolute time would be most similar to :
mr Goodwill [35]
The absolute time would be most similar to a fact. It was theorised and in fact, approved by scientists as a scientific law which governs, according to Wikipedia, as a "<span>true and mathematical </span>time<span>, of itself, and from its own nature flows equably without regard to anything external, and by another name is called duration: relative, apparent and common </span><span>time."</span>
6 0
3 years ago
قواعد البيانات الموزعه​
Monica [59]

Answer:

Translation : Distributed Databases

Explanation:

6 0
3 years ago
What are three recommendations for reducing risk and improving the privacy of your personal information while using social media
viktelen [127]

Answer:

1. Treat the “about me” fields as optional.

2. Become a master of privacy settings.

3. Know the people you friend.

Explanation:

1. Treat the “about me” fields as optional.

Because these fields are offered, however, doesn’t mean you must fill them out. Consider offering a general version of the information requested or simply leaving the field blank. For instance, listing only your state of residence, instead of both city and state, can make it harder for others to figure out exactly where you live.

2. Become a master of privacy settings.

All social media sites give you the option to limit post viewing to specific audiences. Take the time to explore these settings, try different options, and become a master of their use.

3. Know the people you friend.

Once upon a time, social media users competed with one another to have the largest number of connections. Today, however, smart social media users know that the more people you’re connected to, the harder it is to control what happens to the information you post. Make sure you know the people you add on social media, in real life if possible. Don’t hesitate to use the “block” feature when the situation seems to call for it.

6 0
3 years ago
Other questions:
  • HELPPP!!! ASAP *What are the purposes of a good web page?*
    14·1 answer
  • Which of these is not one of the main parts of an email?
    10·2 answers
  • How do you change brightness on acer laptop?
    7·1 answer
  • When transporting data from real-time applications, such as streaming audio and video, which field in the ipv4 header can be use
    14·1 answer
  • You are comparing cryptographic solutions to implement at your organization. Which two items should you focus on when you are ev
    12·1 answer
  • A human interest story is an example of hard news.<br> O True<br> O False HEL
    15·1 answer
  • Another one please help quick i got to go soon
    7·1 answer
  • How does an extranet work?
    15·1 answer
  • Which type of network consists of multiple Windows computers that share information, but no computer on the network serves as an
    15·1 answer
  • In which of the following movies, multimedia's special effect is used ? *
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!