Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need Help on Java H/W. Thanks Student 123 150 999 100 225 849 123 123 150 643 Fi

ID: 3842423 • Letter: N

Question

Need Help on Java H/W. Thanks

Student

123
150
999
100
225
849
123
123
150
643

First Name

Tim
Diablo
Tom
Buffy
LeROY
Bruce
Tom
Dick
Harry
Jane

Last Name

Smith
HO
Doe
Slayer
Jackson
Lee
Smith
Smith
HO
Doe

DOB

19960215
19900420
19860215
19960314
20001114
19560215
19890130
19880615
19870420
19860210

Address

777 Heavens Way
666 Hells Gate
999 Nevermind
456 seven
123 Right Here Alley
333 Enter the Dragon
321 zero
836 Pick Up Sticks
577 Eleven
888 Haight

ask 1 Use java io File to input information on 10 students into a text file. student ID, First Name, Last Name, DOB, and address. Create a header row for your student information. Attach Snipping photo source code and file containing student information. (See attached text file photo below.) outputile Notepad File Edit Format View Help student ID# First Name Address Last Name DOB Smith 123 19960215 777 Heavens Way Tim Diablo 19900420 666 Hells Gate 150 HO 19860215 999 Nevermind 999 Tom Doe 100 Buffy 19960314 456 Seven 123 Right Here Alley 25 20001114 LeRoy 19560215 849 333 Enter the Dragon Bruce Lee 19890130 123 Smith 321 zero Tom 19880615 Dick Smith 836 Pick Up sticks 123 19870420 577 Eleven 150 Harry Ho 888 Haight 19860210 643 Jane Doe

Explanation / Answer

Hi, Please find my implementation.

######## input file ########

123, Tim , Smith , 19960215 , 777 Heavens Way

150, Diablo , HO , 19900420 , 666 Hells Gate

999, Tom , Doe , 19860215 , 999 Nevermind

100, Buffy , Slayer , 19960314 , 456 seven

225, LeROY , Jackson , 20001114 , 123 Right Here Alley

849, Bruce , Lee , 19560215 , 333 Enter the Dragon

123, Tom , Smith , 19890130 , 321 zero

123, Diick , Smith , 19880615 , 836 Pick Up Sticks

150, Harry , HO , 19870420 , 577 Eleven

643, Jane, Doe, 19860210 , 888 Haight

#########

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class StudentInfoFromFile {

  

   public static void main(String[] args) throws FileNotFoundException {

      

       Scanner sc = new Scanner(System.in);

       System.out.print("Enter input file name: ");

       String fileName = sc.next();

      

       Scanner fileScanner = new Scanner(new File(fileName));

      

       System.out.println("Student ID# First Name Last Name DOB Address");

      

       while(fileScanner.hasNextLine()) {

           String line = fileScanner.nextLine();

          

           // splitting by comma(,)

           String[] str = line.split(",");

           //System.out.println(Arrays.toString(str));

          

           System.out.println(str[0].trim()+" "+str[1].trim()+" "+str[2].trim()+

                   " "+str[3].trim()+" "+str[4].trim());

          

       }

      

       fileScanner.close();

       sc.close();

   }

}

/*

Sample run:

Enter input file name: mydata.txt

Student ID#       First Name       Last Name       DOB           Address

123           Tim           Smith           19960215       777 Heavens Way

150           Diablo           HO           19900420       666 Hells Gate

999           Tom           Doe           19860215       999 Nevermind

100           Buffy           Slayer           19960314       456 seven

225           LeROY           Jackson           20001114       123 Right Here Alley

849           Bruce           Lee           19560215       333 Enter the Dragon

123           Tom           Smith           19890130       321 zero

123           Diick           Smith           19880615       836 Pick Up Sticks

150           Harry           HO           19870420       577 Eleven

643           Jane           Doe           19860210       888 Haight

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote