Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package br.com.geracao.main;
- import java.io.File;
- import java.io.PrintWriter;
- import javax.swing.JOptionPane;
- public class EscritorDeNotas {
- public static void main(String[] args) {
- float[] notas = { 9.5f, 9.2f, 9.2f, 8.5f, 8.2f, 8.0f, 8.0f, 8.0f, 7.7f, 7.6f, 7.4f, 7.2f, 6.8f, 6.2f, 5.1f, 4.6f, 4.6f, 3.8f, 2.5f };
- File file = new File("C:\\arquivo.txt");
- try {
- PrintWriter pw = new PrintWriter(file);
- for (int i = 0; i < notas.length; i++) {
- pw.println(notas[i]);
- }
- pw.close();
- JOptionPane.showMessageDialog(null, "Cadastro realizado com sucesso!");
- } catch (Exception e) {
- JOptionPane.showMessageDialog(null, "Erro ao escrever no arquivo (" + e.getLocalizedMessage() + ").");
- }
- JOptionPane.showMessageDialog(null, "Programa finalizado.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement