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
Jlenok [28]
3 years ago
11

Write a program that uses the Purchase class in 5.13. Set the prices to the following: Oranges: 10 for $2.99 Eggs: 12 for $1.69

Apples: 3 for $1.00 Watermelons: $4.39 each Bagels: 6 for $3.50 Set the purchased quantity to the following: 2 dozen oranges, 2 dozen eggs, 20 apples, 2 watermelons, 1 dozen bagels Display the total cost of the bill
Computers and Technology
1 answer:
Xelga [282]3 years ago
5 0

Answer:

Explanation:

The following program is written in Java. Using the program code from Purchase class in 5.13 I created each one of the fruit objects. Then I set the price for each object using the setPrice method. Then I set the number of each fruit that I intended on buying with the setNumberBought method. Finally, I called each objects getTotalCost method to get the final price of each object which was all added to the totalCost instance variable. This instance variable was printed as the total cost of the bill at the end of the program. My code HIGHLIGHTED BELOW

//Entire code is in text file attached below.

//MY CODE HERE

       DecimalFormat df = new DecimalFormat("0.00");

       oranges.setPrice(10, 2.99);

       oranges.setNumberBought(2*12);

       eggs.setPrice(12, 1.69);

       eggs.setNumberBought(2*12);

       apples.setPrice(3, 1);

       apples.setNumberBought(20);

       watermelons.setPrice(1, 4.39);

       watermelons.setNumberBought(2);

       bagels.setPrice(6, 3.50);

       bagels.setNumberBought(12);

       totalCost = oranges.getTotalCost() + eggs.getTotalCost() + apples.getTotalCost() + watermelons.getTotalCost() + bagels.getTotalCost();

       System.out.println("Total Cost: $" + df.format(totalCost));

   }

}

You might be interested in
Simplify the Boolean expression (AB(C + BD) + AB]CD.
finlep [7]

Explanation:

Simplify the Boolean expression (AB(C + BD) + AB]CD.

6 0
3 years ago
Read 2 more answers
Ranges of IP address that anyone can use for their internal networks are known as ______.
Rama09 [41]
Since no answer choices, have to deduce it is Private Networks
8 0
3 years ago
Read 2 more answers
A website whose URL ends with .gov, .edu, or .org is necessarily a reliable source. True or False
natali 33 [55]
True because they are educational anything .com and sometimes .net because .gov is from the government so it is very safe to use and .edu is for education it is always used to help people with education etc and .org is   public which other people can say false and save you from false information
7 0
3 years ago
Technology can most broadly be defined as anything that does which of the following ?
Anastasy [175]
I would say A. Allowing us to improve efficiency in the workplace has helped grow our economy and we can thank technology for that. Due the it always improving our lives only get that much easier.
5 0
3 years ago
____ is a limited version of windows that allows you to use your mouse, screen, and keyboard but no other peripheral devices.
Gnoma [55]
'SAFEMODE' <span>is a limited version of windows that allows you to use your mouse, screen, and keyboard but no other peripheral devices.</span>
8 0
3 years ago
Other questions:
  • A ________ is s field or set of fields in a record that uniquely defines the record.
    7·1 answer
  • You are in charge of designing a menu tree for navigating 1,250 books in a digital library. Present an argument of whether the m
    12·1 answer
  • Why is it so important that you know how much traffic dfs replication requires?
    13·2 answers
  • Take some time to do some research about small businesses in your area. Select one and using HTML design a simple site that educ
    11·1 answer
  • Describe the functions of ALU, resisters, CU, BIU, Cache and FPU.
    7·1 answer
  • NAND is logically complete. Use only NAND gates to constructgate-level circuits that compute the
    7·1 answer
  • The program DebugTwo2.cs has syntax and/or logical errors. Determine the problem(s) and fix the program.// This program greets t
    5·1 answer
  • What is the output of the following code:
    12·1 answer
  • Subscribe too my you tube channel for a brainiest
    15·1 answer
  • When would instant messaging be the least effective means of communication
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!