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
If Mark is developing a website to be optimized for mobile devices, what would be the top-level domain?
umka2103 [35]

Answer:

A top-level domain or the TLD is the domain at the highest level in the hierarchy of the DNS. And that means in the Internet DNS. Also, the top-level domain is installed in the namespace toot zone. And the top-level domain is the .com, in general, to be named as the best one. The next two are the .net and .org. But since it is required to optimize the website for the mobile devices, we should select here .com.

Explanation:

Please check the answer section.

5 0
3 years ago
How to unlock your iphone when you forgot the password?.
Lena [83]

Answer:

go to customer service

Explanation:

5 0
2 years ago
What are the two different types of dns requests?
Fantom [35]

The two major types of DNS request are as follows;

  • Recursive Query
  • Iterative Query

<h3>What is a domain name system?</h3>

Domain name system is abbreviated as DNS.

A Domain Name System (DNS) converts domain names into IP addresses, which allow browsers to get to websites and other internet resources.

Basically,  DNS is a directory of names that match with numbers.

Computer uses IP addresses to communicate, therefore, the DNS convert domain names to IP address for communication.  

The two major types of DNS request are as follows;

  • Recursive Query - Query that demands a resolution
  • Iterative Query - Query that does not demand a resolution.

learn more on DNS here: brainly.com/question/14397200

#SPJ11

6 0
2 years ago
Read 2 more answers
How are charts inserted into a PowerPoint slide?
atroni [7]
It’s the third one.
7 0
3 years ago
Read 2 more answers
What is unique about a dual-axis chart?
antiseptic1488 [7]

Answer:

B: data is charted by two different types of data.

Explanation:

Got it correct in edge.

4 0
3 years ago
Read 2 more answers
Other questions:
  • Designing the moving parts of a car—including the engine, drivetrain, steering, and brakes—is done by what type of engineer?
    11·2 answers
  • When numbers are changed in cells that are involved in formula is the formulas are automatically
    14·1 answer
  • Suppose arraylist list1 is [1, 2, 5] and arraylist list2 is [2, 3, 6]. after list1.addall(list2), list1 is __________.
    8·1 answer
  • You are adding new wires in your building for some new offices. The building has a false ceiling that holds the lights and provi
    8·1 answer
  • How can you autohide the taskbar in Windows 10?
    8·2 answers
  • Write a program that reads students’ names followed by their test scores. The program should output each student’s name followed
    13·1 answer
  • 2 (01.01 LC)
    5·1 answer
  • Which activity represents a violation of the licensing agreement?
    13·2 answers
  • What do astronomers call a system that is composed of more than two stars?
    9·2 answers
  • A variable is assigned a value on line 328 of a program. Which of the following must be true in order for the variable to work?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!