Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Questions:

1. Write a programme that computes the rental charge given the type of moped, when it is rented (weekday or weekend), and the number of hours rented.

The rental charges are as follows:

(a) Type of moped '50cc Mopette': Weekly rental is $15 for the ?rst 3 hours and $2:50 per hour after the ?rst 3 hours. Weekend rental is $30 for the ?rst 3 hours and $7:50 per hour after the ?rst 3 hours.

(b) Type of moped '250cc Mohawk': Weekly rental is $25 for the ?rst 3 hours and $3:50 per hour after the ?rst 3 hours. Weekend rental is $35 for the ?rst 3 hours and $8:50 per hour after the ?rst 3 hours.

Create a class called Moped with appropriate data members (attributes or properties) and methods. Be sure to have a constructor that can accept the size (50cc or 250cc) to determine the type of moped and another one for the different default rental amounts. The class design should include:

(a) Data Members (attributes): size, dayOfWeek, hours, name, three- HourPrice, hourlyPrice, totalCost.

(b) Constructors: Moped() (default values will be for 50cc) andMoped(int size, String day, int hours).

(c) Accessor (Get) Methods: getSize(), getDayOfWeek(), getHours(), getName(), getThreeHourPrice(), getHourlyPrice(), getTotalCost().

(d) Mutator (Set) Methods: setSize(int s), setDayOfWeek(String d), setHours(int h).

(e) Computation Methods: computeTotalCost, mopedName, isWeekend (you can also add some helper methods if you need).

The following UML diagram might be of assistance:

2. Write a driver class called MopedRental. This class should perform the following: asks the user to enter the size of the moped, the day of the week and the number of hours rented, creates the Moped object, based on the size, and displays the input data, type of moped and the total cost of the moped rental. Use the appropriate format for the output values.

3. Scoring in a single game of tennis starts with love-all, then scores of 15, 30, and 40. A player wins when he or she is two points ahead of their opponent and has a score of over 40, where the terms advantage server, deuce (tied score), and advantage receiver are used when the score is 40-all or higher.

Prepare a class called TennisGame that can be used to encapsulate the score in a single game of tennis. Then write a driver program called TennisSet, that plays a set of ?ve games of tennis between two players A and B (randomly choosing the winner of each point), ideally alternating the server for each game, and outputting a commentary of the progress and result of each game.

Java, Programming

  • Category:- Java
  • Reference No.:- M9395087
  • Price:- $55

Priced at Now at $55, Verified Solution

Have any Question?


Related Questions in Java

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As