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
I need a C++ program to ask the user to put in different numbers until zero is pressed then the program counts the numbers that
frozen [14]

Answer:

#include <iostream>

using namespace std;

int main()

{

int input = 0;

int count = 0;

int sum = 0;

int sumNegative = 0;

while (true) {

 cout << "Enter a number: ";

 cin >> input;

 if (input == 0) break;

 count++;

 sum += input;

 if (input < 0) {

  sumNegative += input;

 }

}

cout << "Count of the numbers: " << count << endl;

cout << "Sum of all the numbers: " << sum << endl;

cout << "Sum of the negative numbers: " << sumNegative << endl;

}

Explanation:

Your requirements regarding the sum and the negative numbers was a bit vague so I just did something you can probably adjust easily to your liking.

7 0
3 years ago
1. What arguments can you make for the idea of a single language for all programming domains
SVEN [57.7K]

Answer:

The answer to this question defined below.

Explanation:

It's a smart idea to get a common language for coding of every kind. It would help all developers and customers understand the language better because, in every case, there's no more need to learn, that language.  

  • This could also render software developed in the very same language consistent, and therefore, ports on multiple platforms are not required.
  • In this process, we talk about the common property and function of the classes, that's why it is the correct answer.
3 0
3 years ago
_______ is a form of crime that targets a computer system to acquire information stored on that computer system, to control the
postnew [5]

Answer: Computers as target

Explanation:

Whenever an authorized  access is made into a system it is a form of crime and it is called computers as target whereby one is able to access the system and get hands on unauthorized data and can also manipulate various activities which will have many dangerous effects.

8 0
3 years ago
If the motherboard is not getting power, it will not start the boot. ... A four-year old laptop will not boot and presents error
lakkis [162]

Answer:

<em>The right order of steps you should take to repare the laptop is: D A C B</em>

<em>Explanation:</em>

<em>D. Ask yourself if the laptop is still under warranty: Because they will replace the board for you or give you a new machine.</em>

<em>A. Ask yourself if replacing the motherboard will cost more than purchasing a new laptop: since technology evolve every day, you might consider buying a new faster, better, advanced machine.</em>

<em>C. Find the service manual to show you how to replace the motherboard: the support assistence will guide you trhough the right way of replacing the board.</em>

<em>B. Find a replacement motherboard: choose the specific one or maybe try to find a better model, that can improve your computer performance.</em>

7 0
3 years ago
How do you write 124.59 in expanded form?
scZoUnD [109]
124.59 in expanded form is:

100 + 20 + 4 + 0.5 + 0.09
8 0
3 years ago
Read 2 more answers
Other questions:
  • A _____ is a harmful program that resides in the active memory of a computer and duplicates itself. Select one: a. scareware b.
    7·1 answer
  • You are late in the preparation of the computer graphics for your final report and presentation. You run into a friend who is gr
    13·1 answer
  • Monitors display images by using a grid made up of millions of tiny dots, called ________.
    13·1 answer
  • Wrtie a program in which we will pass a value N. N can be positive or negative. If N is positive then output all values from N d
    8·1 answer
  • Which actions are available in the Trust Center? Check all that apply.
    8·1 answer
  • What does NOT match with Agile Manifesto?
    9·1 answer
  • The way a student prepares for a test or reviews academic material is referred to as
    8·2 answers
  • How do we prevent electrical problems as prescribe by the course?​
    11·1 answer
  • As you are discussing marketing with a client, you try to explain how individuals find sites. Which tool will you explain as the
    8·1 answer
  • Define management styles
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!