Preview

Java Programming: Mutator Method Assignment Q&A

Satisfactory Essays
Open Document
Open Document
341 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Java Programming: Mutator Method Assignment Q&A
Exercise 4.32
[Assessment 2(16): You must have this exercise signed off by your class supervisor]

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

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Pt1420 Unit 4

    • 4123 Words
    • 17 Pages

    If the dual price for b1 is 2.7, the range of feasibility is 20 ≤ b1 ≤ 50, and the original value of b1 was 30, which of the following is true?…

    • 4123 Words
    • 17 Pages
    Satisfactory Essays
  • Powerful Essays

    POW 9 IMP3

    • 1192 Words
    • 5 Pages

    Create 2 formulas, one that will calculate the last number in terms of the first number and a constant increase in rate as well as the total amount of numbers. The second formula will add ass of the resulting numbers from the first formula together after the last number is calculated.…

    • 1192 Words
    • 5 Pages
    Powerful Essays
  • Satisfactory Essays

    QNT351 Week5 MyStatsLab

    • 2853 Words
    • 9 Pages

    a. z < - 1.645 b. z > 2.575 c. z < - 1.28 or z > 1.28 d. z < - 2.33…

    • 2853 Words
    • 9 Pages
    Satisfactory Essays
  • Satisfactory Essays

    PT1420week5exdkinney

    • 404 Words
    • 2 Pages

    VB supports many mathematical and/or numeric functions that can make calculations and other procedures very simple, as one just have to feed in the variables, and get the output after the function processes it. One such function is:…

    • 404 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Numbers are ordered. One number is greater than, less than, or equal to another number.…

    • 529 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Mm207 Unit 2

    • 520 Words
    • 3 Pages

    Use the second given value as the reference value. Also, write a statement describing the result.…

    • 520 Words
    • 3 Pages
    Satisfactory Essays
  • Better Essays

    If you find yourself spending more time with your I-pod than your television, have a large hard drive for your computer devoted solely to music files, or make like the kids in the popular television series “Glee” and randomly burst into song, then you most likely consider yourself quite the music aficionado.…

    • 1480 Words
    • 6 Pages
    Better Essays
  • Satisfactory Essays

    Optimization and Brand

    • 846 Words
    • 4 Pages

    4X + 4Y < 30 Nutrient C 4X + 4Y = 30; when x = 0, y = 7.5; when x = 7.5, y = 0…

    • 846 Words
    • 4 Pages
    Satisfactory Essays
  • Powerful Essays

    As if the music industry has not seen enough change in recent years, Pandora Radio has started yet another music revolution. This time, however, the revolution is not about how the music is stored and collected (LP/CD/MP3 transformation), or how music is purchased (Record Stores/ iTunes transformation), but how we actually listen to music. Pandora Radio has created an amazing technology, which allows users to create and customize their own radio stations that automatically play new and unique songs that cater exactly to the users tastes and interests. Pandora has created a radio station that never plays that bad or annoying song. With Pandora, the user will never have to turn that proverbial dial ever again.…

    • 1237 Words
    • 5 Pages
    Powerful Essays
  • Good Essays

    Pandora’s Music Genome Project offers a unique value proposition in that it provides users with their preferred genre of music based on a single input. They have a large collection of songs in their database categorized into 65 million stations. Users are able to pick multiple genres or create ‘listening stations’ based on musical style, artist, song or composer. This ‘hands-free’ or minimal-interaction listening service was an innovative idea and offered a distinctive listening experience to the user—a service provided by none other.…

    • 761 Words
    • 4 Pages
    Good Essays
  • Better Essays

    data needed to generate an edit file, but it will replace the appropriate music id so that the file…

    • 1237 Words
    • 4 Pages
    Better Essays
  • Good Essays

    A Robotics Project

    • 2387 Words
    • 10 Pages

    Tests Function - play the chosen song 3 times non stop, if it works well it will play the music without any complications. Play/create recognisable music - we can ask 5 people to listen to our robot and see if they recognise…

    • 2387 Words
    • 10 Pages
    Good Essays
  • Good Essays

    sing k box

    • 849 Words
    • 4 Pages

    All user of the application can vote the songs posted. The “Voting” page will display ranking list by voting.…

    • 849 Words
    • 4 Pages
    Good Essays
  • Better Essays

    I was looking for something interesting around the school campus when I notice a PHILIPS™ double-decker bus, so curious I decided to check in to actualize what was going on, after getting in touch with the promotional crew I got to understand they were creating awareness for their music and sound products which is going to be release in the market by next year 2014. This gave me an inspiration idea as we all know music is an art form whose medium is sound and silence. In many cultures, music is an important part of their way of life and as we all know music is often ordered and pleasant to listen too. As we all watch foreign and local musician on TV’s and as their music is played on the radio this clearly states that the entertainment sector is growing and is promoted by the media/telecommunications company day by day. Nowadays people even listen to music on their ipods, iphones, ipads or any other mobile device. hence local or foreign music, ranging from a different genres like Rock, Soul, Hip Hop and R n B for fun , entertainment , inspiration , motivation and other recreational activities. At Most time I myself always listen to music either on my phone or laptop devices ,also with the rising trend of technology and high level market competition people are so eager to use and be updated about latest technology…

    • 1283 Words
    • 6 Pages
    Better Essays
  • Good Essays

    ✓ SOLUTION: Ts will ask for a reason and explain the importance of the song for the lesson.…

    • 956 Words
    • 4 Pages
    Good Essays

Related Topics