How can I fix my simple Java program?
-
Okay, I only need help with reading the file or case 1 in the switch. I am supposed to use a void method but I don't know what to put in the parameters or what to return? Help? import java.io.*; import java.util.*; import java.text.*; public class MP3 { final int MAXsongs = 100; // max amount of info on a file final int MAXartists = 100; final int MAXalbums = 100; String[] Song = new String [MAXsongs]; // arrays for text String[] Artist = new String [MAXartists]; String[] Album = new String [MAXalbums]; String line = null; int countS = 0; // counter for songs in program int countB = 0; // counter for artists in program int countA = 0; // counter for albums in program public void Read (double output) throws IOException //to open and view the database { BufferedReader reader = new BufferedReader (new FileReader ("JonsData.txt")); System.out.println ("This is your music collection: "); while ((line = reader.readLine ()) != null) { Song [countS] = (line); line = reader.readLine (); Artist [countB] = (line); line = reader.readLine (); Album [countA] = (line); System.out.println (Song [countS]); // output read info to the screen System.out.println (); System.out.println (Artist [countB]); System.out.println (); System.out.println (Album [countA]); countS++; countB++; countA++; } reader.close (); } public static void main (String str[]) throws IOException { BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in)); DecimalFormat df = new DecimalFormat ("#"); int menu; // switch System.out.println ("Welcome to your database"); System.out.println (); System.out.println ("1: Open and veiw your collection"); System.out.println ("2: Add a file to your collection"); System.out.println ("3: Search by: category, titles, artists"); System.out.println ("4: Sort by: category, titles, artists"); System.out.println ("5: Create a backup of the collection"); System.out.println ("6: Delete a song from the collection"); System.out.println ("7: Allow multiple users to create other databases as well"); System.out.println (); System.out.println ("Which option would you like to choose?"); // asks user to choose 1 of 7 options menu = Integer.parseInt (stdin.readLine ()); switch (menu) { case 1: Read (); break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: break; case 7: break; default: System.out.println ("Not an option"); } } }
-
Answer:
It might actually be less effort to learn how to program rather than reposting your question every 20 minutes, incrementally getting it written for you.
World Industries at Yahoo! Answers Visit the source
Other answers
It doesn't look like your file should take any parameters. Try deleting the part where you wrote "double output". Also, you don't need to return anything since this is a void method. Void methods never return a value.
Marquis de Laffayette
Related Q & A:
- How can I analyze my simple project using sonar?Best solution by Stack Overflow
- How can I fix parser Error in ASP.NET?Best solution by parse.com
- How can I fix a radio antenna?Best solution by wikihow.com
- How can I fix my IPOD?Best solution by Yahoo! Answers
- I can not send out my emails! How can I fix it.
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.