Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I admit that I have struggled with if/then statements and arrays. I am trying to calculate fees for renting a television for a certain amount

I admit that I have struggled with if/then statements and arrays. I am trying to calculate fees for renting a television for a certain amount of weeks. Here is my code, when tested it does not return the correct values. Any help would be more than appreciated!

/** * This class represents a television to be rented. * */ public class Television implements Item { public static final double DELTA = 0.001;

private String Description; private Money WeeklyRate; private String Id; private Money calculateFee; private int size; private String type; private boolean rented; private boolean returned; private boolean isRented; /** * Constructor for objects of class Television. */ public Television() { this.Description = ""; this.WeeklyRate = new Dollar(); this.Id = ""; this.type = ""; this.size = 0; this.calculateFee = null; this.rented = false; this.isRented = false; this.returned = false; }

/** * Return the description of the Television. * @return the description. */

public String getDescription() {

return this.Description; }

/** * Change the description of the television to the * given parameter. * @param desc the new description. */ public void setDescription(String desc) { this.Description = desc; }

/** * Return the weekly rental rate for the television. * @return the rate. */ public Money getWeeklyRate() { return WeeklyRate; }

/** * Change the weekly rental rate of the television * to the given parameter. * @param wklyRate the new weekly rate. */ public void setWeeklyRate(Money wklyRate) { this.WeeklyRate = wklyRate; }

/** * Return the ID of the television. * @return the ID. */ public String getId() { return this.Id; }

/** * Change the ID of the television to the given * parameter. * @param idNum the new ID. */ public void setId(String idNum) { this.Id = idNum; }

/** * Calculate the fees for renting the television for a given * number of weeks. The weekly rate must be set and the * number of rental weeks must be valid in order for the fee * to be calculated. * @param weeks the number of rental weeks * @return the fee or null if the fee could not be calculated */ public Money calculateFee(int weeks) { if (weeks == 0) { return null; } else if (weeks > 0 && weeks <= 4)

{ return WeeklyRate = WeeklyRate.mul(weeks); }

return null; }

/** * Return the size of the television. * @return the size. */ public int getSize() { return this.size; }

/** * Change the size of the television to the given * parameter. * @param screenSize the new size. */ public void setSize(int screenSize) { this.size = screenSize; }

/** * Return the type of the television. * @return the type. */ public String getType() { return this.type; }

/** * Change the type of the television to the given * parameter. * @param screenType the new type. */ public void setType(String screenType) { this.type = screenType; }

/** * Indicate the television has been rented. */ public void rented() { this.rented = true ; }

/** * Indicate the television has been returned and is no * longer rented. */ public void returned() { this.returned = false ; }

/** * Return the rental status of the television. * @return true if the television is rented, otherwise false. */ public boolean isRented() { if (isRented == true) { return true; } else return false ; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

=+ Be able to differentiate misbehavior from performance issues.

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago