Create a text file.
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.
PLEASE ATTACH SNIPPING PHOTO SOURCE CODE AND FILE CONTAINING STUDENT INFORMATION! This is the most important. (See attached text file photo below.) Thank you :).
Online resource: http://t utorials.jenkov.com/java-io/file.html
Please follow the code and comments for description :
CODE :
import java.io.BufferedWriter; // required imports
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class StudentInfo { // class to run the code
public static void main(String[] args) { //
driver method
try { // try catch block
of code
File file = new File("studentData.txt"); // get the file object for
the text file, provide the whole path directory if is out of the
java program's class directory
int sId[] = {123, 150, 999, 100, 225, 849, 123, 123, 150, 643}; //
required variables
String fname[] = {"Tim", "Diablo", "Tom", "Buffy", "LeRoy",
"Bruce", "Tom", "Dick", "Harry", "Jane"};
String lname[] = {"Smith", "Ho", "Doe", "Slayer", "Jackson", "Lee",
"Smith", "Smith", "Ho", "Doe"};
String dob[] = {"19960215", "19900420", "19860215", "19960314",
"20001114", "19560215", "19890130", "19880615", "19870420",
"19860210"};
String addr[] = {"777 Heaven 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"};
// if file doesnt exists, then create it
if (!file.exists()) {
System.out.println("Creating the File..."); // message
file.createNewFile(); // call the method to create the file
}
FileWriter fw = new FileWriter(file.getAbsoluteFile()); // create
the writer object for the file
BufferedWriter bw = new BufferedWriter(fw); // buffered writer
class for the file writer
System.out.println("Writing Data to the File..."); // message
bw.write(String.format("%-15s %-15s %-15s %-15s %-15s",
"StudentID#", "First Name", "Last Name", "DOB", "Address")); //
format the header
bw.write("\n"); // new line character
for (int i = 0; i < 10; i++) { // iterate over the index
values
int id = sId[i]; // get the respective values
String fn = fname[i];
String ln = lname[i];
String birth = dob[i];
String add = addr[i];
bw.write(String.format("%-15s %-15s %-15s %-15s %-15s", id, fn, ln,
birth, add)); // write the formatted data to file
bw.write("\n"); // new line character
}
bw.close(); // close the file
System.out.println("Completed Writing Data to the File."); // message
} catch (IOException
e) { // catch any exceptions
e.printStackTrace();
}
}
}
OUTPUT :
Creating the File...
Writing Data to the File...
Completed Writing Data to the File.
ScreenShot :
Hope this is helpful.
Create a text file. Use java.io File to input information on 10 students into a text...
Must be written in JAVA Code Write a program that will read in a file of student academic credit data and create a list of students on academic warning. The list of students on warning will be written to a file. Each line of the input file will contain the student name (a single String with no spaces), the number of semester hours earned (an integer), the total quality points earned (a double). The following shows part of a typical...
in
csis 152 style
python programming language
Read the initial employee information from a text file and store the employee information into a list of sublists called empRoster. Each sublist should contain [empID, name, payrate,hours] Here's an example of how empRoster will look: 111, "Sally Smith", 10, 401, 1222, "Bob Brown", 10, 42]1 The text file will be structured as shown below, where each line contains the employee id, employee name, payrate and hours. Each entry on the line is...
The ", delimiter" should now be changed to use the "^ delimiter". There needs to be an 2nd address field added to the original code, as well as, a "plus 4" on the zip code (example: 47408-6606). Then the additional prompts must be added. Thank you! Last Real-World problem (in module 04 - 05), you added functionality to allow the user to enter multiple patients until the user indicated done. You are to enhance this functionality. Add the following functionality...
484 Core Concepts of Accounting Information Systems a. Using Access, create an employee table sim- ilar to the one shown in Figure 15-4. Create created. (Hint You can use the aforemen- tioned expression for the department code as a validation rule.) at least one record for this table b. Create validation rules for the listed restric tions and an accompanying validation text for each. Document your work by provid- ing a table outlining exactly what rules you c. Test each...