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

In Java, w rite a program to get input from the user using dialog boxes. The pro

ID: 3553122 • Letter: I

Question

In Java, write a program to get input from the user using dialog boxes. The program should repeatedly input 3 pieces of information: An employee's full name, their hourly rate of pay, and the total number of hours that they worked during the previous week. The program should write this information to an OutputFile object. When this program ends, you will have a text file that will have records with 3 fields of information in each record and would look something

"Bob Jones" 40.0 10.25

"Sam Smith" 45.5 15.00

"Jodi White" 32.25 20.50

etc.

Notice that the name has quotes around it (use the writeString( ) method to automatically put quotes around the employee's name). You can use any method you choose to stop the program. Be sure to close the OutputFile at the very end of the program or the data will not appear in the file.


Do not specify a drive or path in the program. Only put the name of the file that you want to create such as:

pay = new OutputFile("payroll.txt");

Explanation / Answer

import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; public class writer { public void writing() { try { //What ever the file path is. File statText = new File("info.txt"); FileOutputStream is = new FileOutputStream(statText); OutputStreamWriter osw = new OutputStreamWriter(is); Writer w = new BufferedWriter(osw); w.write("input"); // Here input would be whatever you want to give input. w.close(); } catch (IOException e) { System.err.println("Problem writing to the file statsTest.txt"); } } public static void main(String[]args) { writer write = new writer(); write.writing(); } }

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