Advertisement
Guest User

aiudasergio

a guest
Oct 27th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.io.*;
  4.  
  5. public class Main {
  6. public static void main(String args[]) throws IOException {
  7. String nombre, archivo1 = "ATTT.txt";
  8. double velocidad = 0, velocidades = 0;
  9. int i, mul = 0, mul1= 20, mul2= 50, mul3 = 150;
  10.  
  11. BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
  12. System.out.print("Nombre: ");
  13. nombre = br.readLine();
  14. System.out.print("Cantidad de velocidades: ");
  15. i = Integer.parseInt(br.readLine());
  16.  
  17. try {
  18. File f1 = new File(archivo1);
  19. f1.createNewFile();
  20. } catch (IOException e) {
  21. System.out.print("Error de lectura.");
  22. }
  23.  
  24. for ( int iii = i; iii>0; iii--){
  25. System.out.print("Velocidad: ");
  26. velocidad = Double.parseDouble(br.readLine());
  27. velocidades = velocidad + velocidades;
  28. if (velocidad >= 60 && velocidad <= 119){
  29. mul = mul + mul1;
  30. }else if(velocidad >= 120 && velocidad <= 159) {
  31. mul = mul + mul2;
  32. }else if(velocidad >= 160){
  33. mul = mul + mul3;
  34. }
  35.  
  36. }
  37. if (mul > 0){
  38. System.out.println("Debe: " + mul + " Dolares, multas acumulativas Pagar lo antes posible.");
  39. }
  40. try {
  41. FileWriter fw = new FileWriter(archivo1, true);
  42. BufferedWriter bw = new BufferedWriter(fw);
  43. bw.write(Double.toString(velocidad));
  44. bw.newLine();
  45. bw.flush();
  46. FileWriter fe = new FileWriter(archivo1, true);
  47. BufferedWriter be = new BufferedWriter(fe);
  48. be.write(Double.toString(mul));
  49. be.newLine();
  50. be.flush();
  51. } catch (IOException e) {
  52. System.out.println("Problema de lectura-escritura");
  53. }
  54.  
  55.  
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement