Hi all,
I just entered a Computer Science class and because of an illness I missed a day and fell behind a bit and now am stuck on this homework problem for a program due tomorrow. Here is the directions, its pretty simple program, I'm just struggling with parts of it.
"Write two classes: Track class, TestTrack class. The Track class is the schematic for saving a track from a CD. It should at least store the song title, the artist, and the duration in seconds. (Make the duration a variable of type int.) The track class should have at least one constructor, a method to print the duration in minutes and seconds, and a method to output the complete track information.
To input information, use the Scanner class and to output information, use the JOptionPane.
The TestTrack class contains the main method and asks the user for information about a track, builds a track, then uses the appropriate method to print out a nice formatted version of the information. "
Here is what I have so far:
import java.util.Scanner;
public class Track
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter Song Title: ");
String Title = in.nextLine();
System.out.print("Enter Artist Name: ");
String Artist = in.nextLine();
System.out.print("Enter Track Duration (seconds): ");
int duration = in.nextInt();
}
}
So here is what I'm having trouble understanding.. in the directions am I suppose to display the track info at the end that the user entered? Am I on the right track so far with the track.java file.. I found an example in the book about the test file, but I don't understand anything about it, because it's dealing with a cash register and I am really just having trouble understanding what they are doing in that instance.
How is the test file connected to the main file? In this situation I don't really care if anyone completely tells me how to do this problem, which I would like, but I need a good explanation of why.
Any help is appreciated.
I just entered a Computer Science class and because of an illness I missed a day and fell behind a bit and now am stuck on this homework problem for a program due tomorrow. Here is the directions, its pretty simple program, I'm just struggling with parts of it.
"Write two classes: Track class, TestTrack class. The Track class is the schematic for saving a track from a CD. It should at least store the song title, the artist, and the duration in seconds. (Make the duration a variable of type int.) The track class should have at least one constructor, a method to print the duration in minutes and seconds, and a method to output the complete track information.
To input information, use the Scanner class and to output information, use the JOptionPane.
The TestTrack class contains the main method and asks the user for information about a track, builds a track, then uses the appropriate method to print out a nice formatted version of the information. "
Here is what I have so far:
import java.util.Scanner;
public class Track
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter Song Title: ");
String Title = in.nextLine();
System.out.print("Enter Artist Name: ");
String Artist = in.nextLine();
System.out.print("Enter Track Duration (seconds): ");
int duration = in.nextInt();
}
}
So here is what I'm having trouble understanding.. in the directions am I suppose to display the track info at the end that the user entered? Am I on the right track so far with the track.java file.. I found an example in the book about the test file, but I don't understand anything about it, because it's dealing with a cash register and I am really just having trouble understanding what they are doing in that instance.
How is the test file connected to the main file? In this situation I don't really care if anyone completely tells me how to do this problem, which I would like, but I need a good explanation of why.
Any help is appreciated.