Question

In: Computer Science

Many dog owners see the benefit of buying natural dog food and treats. Dog Day Afternoon...

Many dog owners see the benefit of buying natural dog food and treats. Dog Day Afternoon is a local company that creates its own dog food and treats. Their products are made locally and with natural ingredients. Sales are up and the owners of Dog Day Afternoon have decided to expand their business. Currently they are manually calculating sales. They need a computer program to help speed up the process.

The owners of Dog Day Afternoon decided to get some help. They approached the Career Center and posted numerous temporary programming positions. You are eager to get some experience as a programmer so you apply and get the job.

Your portion of the project is to create a class called DogDay that will take in the quantity and the size of the dog treat. Store these values in attributes called quantity (integer) and size (string). The class will also contain three methods. One method will determine the cost of one dog bone. Name this method DeterminePrice. The cost of the different size natural raw hide bones is as follows:

  • Size A = $2.29
  • Size B = $3.50
  • Size C = $4.95
  • Size D = $7.00
  • Size E = $9.95

Store the cost of each individual dog bone in an attribute called price.

Your second method will be called DetermineTotal. This method will calculate the total cost (quantity * cost) and round this value to 2 decimal places. It will store this value in an attribute called total.

Your final method will return the total.

When creating this class start coding in VS Code or IDLE. To test your class create an object. Send in the values 6 and C. Next call your method DeterminePrice followed by DetermineTotal. Finally print the method ReturnTotal to the screen. Your code should print the following: 29.7

Solutions

Expert Solution

CODE:

class DogDay
{
int quantity;
String size;
  
DogDay(int i, String j)
{
quantity = i;
size = j;
}
  
double price;
void DeterminePrice(){
  
   if(size=="A")
       price = 2.29;
   else if(size=="B")
       price = 3.50;
   else if(size=="C")
       price = 4.95;
   else if(size=="D")
       price = 7.00;
   else
       price = 9.95;
  
}
  
double total;
void DetermineTotal() {
   total = price * quantity;
}
  
void display() {
   System.out.printf("%.2f", total);
}
}


public class Dog {

   public static void main(String[] args) {
       DogDay d1 = new DogDay(6, "C");
       d1.DeterminePrice();
       d1.DetermineTotal();
       d1.display();
   }

}

OUTPUT:

29.70

I have tried to answer the question as briefly and simply as possible if you find any problem in the solution provided ask in comment.


Related Solutions

Max Laboratories is evaluating three independent projects. Project 1: Dog Treats, Project 2: Dog Food, and...
Max Laboratories is evaluating three independent projects. Project 1: Dog Treats, Project 2: Dog Food, and Project 3: Dog Toys. WAAC is 10% Treats Food Toys Cash Flows Initial Investment $         4,000,000 $             3,800,000 $         4,400,000 1 $         1,200,000 $                800,000 $         2,300,000 2 $         1,400,000 $             1,000,000 $         1,900,000 3 $         1,500,000 $             1,700,000 $         1,000,000 4 $         1,800,000 $             2,200,000 $           800,000 Std. Deviation of IRR 10% 8% 12% 1. Calculate Payback Period, NPV, IRR, and MIRR for...
Food buying is changing. Where do you see the future of food buying. Defend your predictions.
Food buying is changing. Where do you see the future of food buying. Defend your predictions.
Wegmans food stores conducted a study to see how many customers will return to the same...
Wegmans food stores conducted a study to see how many customers will return to the same store in the future. The study showed that 40% of the customers visiting a specific store will return in the future to the same store. Suppose seven customers are selected at random, what is the probability that: (a) Exactly four customers will return? (b) All seven customers will return? (c) At least six customers will return? (d) At least one customer will return? (e)...
Given the importance of food to many cultures and people, we oftentimes fail to see how...
Given the importance of food to many cultures and people, we oftentimes fail to see how various cultures can overtly or covertly divulge information about the importance of certain values just by the manner in which items are arranged in a grocery store. For this activity, each student will identify a large grocery store within 5 miles of his/her residence. Please try to identify a large grocery store chain and is a “dominant culture” store (i.e., a Latin specialty version...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT