Java Programming: Mutator Method Assignment Q&A sample essay

On paper, write a method called sum with a while loop that adds up all numbers between two numbers a and b, inclusive, and returns the sum as its result. The values for a and b can be passed to the sum method as parameters. For instance: sum(1, 5) would return the value 15 (i.e., 1 + 2 + 3 + 4 + 5).

What happens if the value of the second parameter is less than the value of the first?

public int Sum (int a, int b) {
int sum = 0;
while (a < b) { sum += a; a++; } Sum += b; return sum ; } Exercise 4.37 [Assessment 2(17): You must have this exercise signed off by your class supervisor] Add a further field, of your choosing, to the Track class, and provide accessor and mutator methods to query and manipulate it. Find a way to use this information in your version of the project; for instance, include it in a track’s details string, or allow it to be set via a method in the MusicOrganizer class. Public Music organizer () { Track = new Arraylist (); Player = new Music player (); Reader = new TrackReader (); Edit = new EditTrack (); Read Library (“audio”); Systems.out.println (“Music library loaded.” + get Number of Track + “tracks.”); System.out.println(); } { Public void edit Track (track) Trackedit (track); } Exercise 4.43 [Assessment 2(18): You must have this exercise signed off by your class supervisor] The java.util package contains the Random class whose nextInt method will generate a positive random integer within a limited range. Write a method in the MusicOrganizer class to select a single random track from its list and play it. Hint: You will need to import Random and create a Random object, either directly in the new method or in the constructor and stored in a field. You will need to find the API documentation for the Random class and check its methods to choose the correct version of nextInt. Import java. Util Random; //random generator Private Random rand; rand = new Random(); public void play randomtrack { Int randomNumber = rand.Nextln (track.size()); playTrack(randomNumber) }

StudyAcer
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work With StudyAcer

StudyAcer

Quality Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

StudyAcer

Qualified Writers

We have hired a team of professional writers experienced in academic and business writing. Most of them are native speakers and PhD holders able to take care of any assignment you need help with.

StudyAcer

Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account.

StudyAcer

Prompt Delivery

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. We will always strive to deliver on time.

StudyAcer

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text.

StudyAcer

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

StudyAcer

Place your order

Fill in the order form and provide all details of your assignment.

StudyAcer

Proceed with the payment

Choose the payment system that suits you most.

StudyAcer

Receive the final file

Once your paper is ready, we will email it to you.

StudyAcer Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

StudyAcer StudyAcer

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

StudyAcer StudyAcer

Admissions

Admission Essays

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

StudyAcer StudyAcer

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

StudyAcer StudyAcer

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied.