CSCI 1010 – Assignment 6
Arrays
Learning Outcomes
Use an array to store data.
Process the contents of an array to determine simple statistical properties.
Required Reading
Savitch - Sections 7.1-7.2
Instructions
For this assignment you will be writing a program that calculates information about a sequence of tracks on an album.
Write a Java main class called YourlastnameProgram6.java (with your actual last name) that does the following:
Displays a welcome message with your name in it.
Prompts for and reads the lengths in minutes and seconds of 12 tracks of an album.
Stores the length of each track in seconds in an array. (Note: total seconds can be computed by multiplying the minutes by 60 and adding the seconds.)
Computes and displays the following:
The shortest track on the album and its length.
The longest track on the album and its length.
The total running time of the entire album.
The average length of a track on the album.
In the output all times should be in the standard minutes and seconds format with a colon in between. This should be done by a private static void function in the main class with the following header:
static void displayTime(int totalSeconds)
number of minutes can be calculated using the / and % operators. Note that if the number of seconds is less than 10, this function must display an extra zero after the colon. For example, a track with a total length of 185 seconds should have its length displayed as 3:05.
Example Input and Output
Welcome to Nicholas Coleman's Album Length Calculator
Please enter all track lengths in minutes and seconds
separated by a space.
Track 1: 3 45
Track 2: 2 3
Track 3: 5 43
Track 4: 6 12
Track 5: 8 11
Track 6: 3 24
Track 7: 4 35
Track 8: 3 12
Track 9: 2 11
Track 10: 7 13
Track 11: 6 24
Track 12: 5 14
The shortest track is #2 at 2:03
The longest track is #5 at 8:11
The total length of the album is: 58:07
The average length of a track is: 4:50