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
Imagine that you work for a company directly related to your major. Your company is preparing for expansion and your boss, Ms. S
shutvik [7]

Answer:

start with what you know

Explanation:

6 0
3 years ago
List the steps to look it install and then run a program or mobile app
Luda [366]

Answer:

1. Open a cloud installer (the source), which is usually Play Store, Aptoide, or UpToDown, in the case of Android phones.

2. Request the package from the server, which will be transmitted via an internet connection. Usually called "downloading".

3. Allow the package provider (mobile store) to install the app on the system, this being the "install" part, where it's put together.

4. Run the app by, usually, pressing the icon in the app drawer.

3 0
3 years ago
Which of the following Office Online apps is most effective for creating spreadsheets?
navik [9.2K]
The answer is C Excel. Excel allows you to make spreadsheets.

Hope this helps :-)
4 0
3 years ago
Read 2 more answers
which application software allows you to compose written ideas on a computer? database, spreadsheet, word processor or graphics
Kazeer [188]
Word processor because it's more for writing
8 0
3 years ago
Which of the following describes the ways organisms are interconnected through their feeding patterns?
quester [9]
The answer is food web.
4 0
4 years ago
Read 2 more answers
Other questions:
  • Which part of the os provides users and applications with an interface to manipulate files?
    8·1 answer
  • It can be useful to have a mentor because they will help you
    7·2 answers
  • What is a step by step procedure written to carry out a task?
    11·1 answer
  • Which of the following is true regarding data acquisition? Because data acquisition is often technical, the research team does n
    15·2 answers
  • You have a small company and want to keep your costs low, but it is important your employees share data. Which network would pro
    5·2 answers
  • Write a program that will open a file named thisFile.txt and write every other line into the file thatFile.txt. Assume the input
    7·1 answer
  • Czy FALL GUYS będzie działało szybko na i5 GH8? Na ilu FPS?
    13·1 answer
  • Type the correct answer in the box. Spell all words correctly. Complete the sentence based on the role education plays to help y
    5·1 answer
  • If you feel your friend had a negative digital identity, what would you do or tell them in order to help them have a positive di
    11·2 answers
  • This is for C++: Using a nested for loop output the following pattern to the screen:
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!