WRITE IN JAVA You are burning some music CDs for a party. You\'ve arranged a lis
ID: 3663862 • Letter: W
Question
WRITE IN JAVA
You are burning some music CDs for a party. You've arranged a list of songs in the order in which you want to play them. However, you would like to maximize your use of space on the CD, which holds 80 minutes of music. So, you want to figure out the total time for a group of songs and see how well they fit. Write and design a java program to help you do this. The time is entered as seconds. For example, if a song takes 6 minutes and 30 seconds to play, the data entered in the data file for that songs would be 390. After all the data has been read, the application should print a message indicating the time remaining on the CD. The output should be in the form of a table with columns and headings written on a file.
Song Number Song Time Total Time
Minutes Seconds Minutes Seconds
__________________________________________
1 5 10 5 10
2 7 42 12 52
5 4 19 17 11
3 4 33 21 44
4 10 27 32 11
5 8 55 41 6
There are 38 minutes and 54 seconds of space left on the 80 minute CD
** Use loop: for (int i=1; 1<=6, i++)
intTmin = 0;
intTmin = Tmin +min; etcetera
This is what I have so far but I do not think it is right:
/* Program Trip:
This program will calculate the time remaining on a CD and will be in the form of a table with each song's time and the total time.
Input: total time for a group of songs.
Output: time remaining on the CD. */
/* Variable Dictionary:
i: Song number.
Stime: Song time in seconds.
Tmin: Total minutes.
Tsec: Total seconds.
min: Minutes.
sec: Seconds. */
import java. util. Scanner;
import java.io.*;
public class Assignment2
{
public static void main (String () args) throws IOException
{
int i, Stime, Tmin, Tsec, min, sec;
PrintWriter outfile = null;
outfile = new PrintWriter (new FileOutputStream ("Time left on CD"));
Scanner keyboard = new Scanner (System.in);
System.out.println ("Enter the song number, the song time, and the total time");
Snumb = keyboard.nextInt ();
Stime = keyboard.nextInt ();
for(int i=1; i<=6, i++);
intSmin=0;
Smin=Smin+min;
intSsec=0;
Ssec=Ssec+sec;
intTmin=0;
Tmin=Tmin+min;
intTsec=0;
Tsec=Tsec+sec;
Explanation / Answer
I had to supplement the COM4J generated classes a bit because the generator didn't do a perfect job:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.