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]
2 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]2 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
Which is most harmful computer virus define​
Ganezh [65]

Answer:

Spyware is the most harmful virus.

It enters into someones computer as a spy and steals the ones personal information, data and other codes.

Explanation:

3 0
3 years ago
How can officers in the armed services receive college educations? Select the best answer choice. A. All of the answers are corr
Ber [7]

Answer:

i think A. is the answer but if it isn't B. Taking courses through the GI Bill is correct

Explanation:

i have multiple friends that are recruiters and i'm in rotc.

4 0
2 years ago
A computer record is used to store all the information about one transaction, but several such records must be used to store the
never [62]

Answer:

True

Explanation:

A single file can be used to record/ store all the information regarding a transaction because in a transaction there are less complexities. a  simple transaction involves an exchange/communication between a buyer and a seller which involves exchange in finances between the buyer and the seller.  

An employee can be involved in several activities like work activities and multiple transactions while a single inventory part record is different from an employee's record and  any other form of transaction. hence separate files have to be created for each of these activities.

To have an easy access to this information when needed a master file is created to store all the individual files.

7 0
2 years ago
How does the speaker feel about traditional forms of poetry
Salsk061 [2.6K]
A speaker sometimes is not able to capture the intended details since it is affected by homophones.
7 0
3 years ago
Read 2 more answers
How Extreme Programming addresses Software Testing andevolution ?
kumpel [21]

Answer:

Extreme programming is a software development technique which is used to enhance software quality and it's response to ever changing customer requirements.

Testing

Testing is main focus in extreme programming.Extreme programming addresses testing in a way that if a minute testing can eliminate a bit of flaws, extensive testing can terminate a lot of flaws.

Evolution in Extreme programming is like this:-

Coding:-First programmers will code the problem.

Testing :- Testing is done to remove flaws.

Listening:- Programmers must listen to the customers to what they need.

Designing:-Then design according to the customer needs.

6 0
3 years ago
Other questions:
  • A local area network works as a ____ network in that clusters of workstations are connected to a central point (hub or switch) t
    6·1 answer
  • Which principle of animation deals with imparting a unique identity to the animated character?
    5·1 answer
  • str1=”Good” str2=”Evening” Does the concatenation of the above two strings give back a new string or does it concatenate on the
    14·1 answer
  • Explain motherboard in detail
    14·2 answers
  • Consumer consequences for illegally downloading software
    6·1 answer
  • There are many commercially made household linens found in the?
    7·1 answer
  • Which step in the software development life cycle analyzes the scope of work?
    6·1 answer
  • Write an algorithm (in pseudocode) for the following Scenario.
    7·1 answer
  • Write in language C, please.
    8·1 answer
  • What is one of four key principles of Responsible Artificial Intelligence
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!