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.:- M9742801

Have any Question?


Related Questions in Java

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

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 ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

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 ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

  • 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