Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3) The class Ticker has been coded as follows: public class Tieket i. privare double price; privare char service; public Ticket double nevprice, char newService

image text in transcribed
image text in transcribed
3) The class Ticker has been coded as follows: public class Tieket i. privare double price; privare char service; public Ticket double nevprice, char newService ! l setPrice( newPrice ): geservice newservice if 1 1 a) Write the mudaters (sotPrice and zetSenice method) for the Ticket class, the price must be greater than or equal to 0 ; the service must be either A or B, the default service is B. b) Write the cccessor (getPrice and gerSerice mothodi) for the Ticket class. c) Code a method that a matchet the value of aervice if it as A, it changes to B, if if is B, it changes 10 in d) Code the toSonng method: ir zeturna the service and pnce separated by a (colon) as in the followang exampley. Exarpla :5 Ei34izs Fraple : c) Code a method that switches the value of service: if it is A, it changes to B; if it is B, it changes to A. d) Code the toString method: it returns the service and price separated by a : (colon) as in the following examples: Example 1: B:34.39 Example 2: A:94.99 Exarple 3: B:44.99 e) What is the data type of the parameter and the retum type of the tax method? Fublse doubie sax fleat rate f) In a clieat class and inside the main method, mr Iickrt is an object reference of type Ticler; call the method tax with my Ticket, assuming a tax rate of 0.06, and assign the resulting tax value to a varable named myI cx. ALCat =axRa:e = 0,064t g) Connder the following sonstant of class indir h) In a client class and mnde nein, inte a statement is cutput the value of the sbove sonstant

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 Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions