Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Java: Write a complete Java class named Dinner that has the following private

ID: 3737974 • Letter: I

Question

In Java:

Write a complete Java class named Dinner that has the following private attributes: Write a complete Java class named Dinner that has the following private attributes: a. An array of String named dishNames. b. An array of double named dishPrices c. An int named numDishes d. A double named taxRate. And the following methods a. public DinnerCO - Creates the arrays (with a size of 10) and initializes the numDishes to zero and the to taxRate 8.875% b. Getters for all the attributes c. public void addDish(String name, double price). This method adds a dish with the d. public double computeTax). This method computes the amount of tax due for the e. public double computeTotalO.This method computes the total amount due for the f. public boolean equalsCObject obj). Two Dinner objects are equal if their numDishes g. public String toString.This method returns an itemized String representing the given name and price to the arrays and maintains the count of dishes in numDishes purchased dishes included in the arrays purchased items included in the arrays, plus the tax that is due. are equal, their taxRate are equal and all their dishNames and dishPrices are all equal receipt of all the dishes purchased, the tax due and the total due.

Explanation / Answer

import java.util.Arrays; public class Dinner { private String[] dishNames; private double[] dishPrices; private int numDishes; private double taxRate; public Dinner() { dishNames = new String[10]; dishPrices = new double[10]; numDishes = 0; taxRate = 0.08875; } public String[] getDishNames() { return dishNames; } public void setDishNames(String[] dishNames) { this.dishNames = dishNames; } public double[] getDishPrices() { return dishPrices; } public void setDishPrices(double[] dishPrices) { this.dishPrices = dishPrices; } public int getNumDishes() { return numDishes; } public void setNumDishes(int numDishes) { this.numDishes = numDishes; } public double getTaxRate() { return taxRate; } public void setTaxRate(double taxRate) { this.taxRate = taxRate; } public void addDish(String name, double price) { dishNames[numDishes] = name; dishPrices[numDishes++] = price; } public double computeTax() { double total = 0; for(int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote