Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IMPORTANT: Always when opening ECLIPSE -> Java Project -> JRE: JavaSE 1.6 (Java environment)
- package PrintWriter;
- import java.io.FileNotFoundException;
- import java.io.PrintWriter;
- import javax.swing.JOptionPane;
- public class PrintWriterPrac {
- public static void main(String[] args) throws FileNotFoundException {
- PrintWriter practice = new PrintWriter ("Stud.txt");
- String name = JOptionPane.showInputDialog("Enter Name");
- String ID = JOptionPane.showInputDialog("Enter Student ID");
- double tuition = Double.parseDouble (JOptionPane.showInputDialog("Enter tuition"));
- // Below are what inputs the information to the txt file
- practice.println("Name: " + name);
- practice.println("Student ID: " + ID);
- practice.printf("Tuition: " + "%.2f", tuition);
- practice.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement