For my menu, I have an option in the menu (case 2) in which to display the contents of the file (" Grade text "). If I'm entering the ideal data:
First name: Fred alias: Smith course: IT mark: 66
This file is saved as Is:
Fred Smith, Computing, 66
Which is correct. However, when I select the option 2 in the menu after displaying the contents of the file, it is displayed:
java.io.FileWriter@55f96302
< P> Now I have looked around and can not find anything like this. If anyone can help solve this issue, I would be grateful. Thanks
Code:
Import java.io.buffferedWriter; Import java.io.filewiter; Import java.io.printWriter; Import java.util.Scanner; Public class test guides {public static zero main (string [] args throws exceptions (file grade = new flamerator ("grade .txt", true); buffed viator live = new buffed vetter (grade); PrintWriter out = new print wall (BW); Scanner Scan = New Scanner (System.in); Int Exam Mark = 0; String First Name = "" String Surname = "; String Course =" "; String Entry =" "; Int Menu = 0; System.out.println ("GradeInter" Pro Welcome to the village!); System.out.println ("menu:"); System.out.println ("1) Enter student grade"); System.out.println ("2) see student grade") ; System.out.println ("3) remove grade"); System.out.println ("4) exit") Menu = scan.nextInt (); switch (menu) {case 1: System.out.print ("Please enter student name first:"); FirstName = Scan. System.out.print ("Please provide the student's alias:"); SurName = scan.next (); System.out.print ("Please student course Select: "); Course = scan.next (); System.out.print (" Please enter student icon: "); While (! Scan.hasNextInt ()) {System.out.print ("Please enter a valid mark:"); Scan.next (); } Examination Mark = Scan. Nxtint (); If (Examination Marks & lt; 40) {System.out.println ("Failed"); } And if (Exam marker = 40 & amp; Exam Marc & lt; = 49) {System.out.println ("3"); } And if (Exam marker = 50 & amp; amp; amp; Examination Marks & lt; = 59) {System.out.println ("2/2"); } And if (Exam marker = 60 & amp; amp; Examination Marks & lt; = 69) {System.out.println ("2/1"); } And if (Examination Mark> = 70 & amp; Examination Marks & lt; = 100) {System.out.println ("First"); } Else {System.out.println ("invalid mark"); } break; Case 2: Systems. Outprintline (grade); Case 3: / * System.out.print ("Please enter the first name that you want to delete:"); If (firstName == scan .next ()) {grade remove (scan.next ()); } * / Case 4: System.out.println (Thank you for using "Grayteenter"); System.exit (0); Default:} Entry = (First name + + "+ + + Name + +", "+ Course +", "+ Examination Marks); Out.println (login); Out.close (); Scan.close (); }}
Add the grade to the firewash so that you can write data to the file. If you want to read the data from the file, you need to use for example FileReader and then print the contents of the file
No comments:
Post a Comment