Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.*;
- public class Main {
- public static void main(String args[]) throws IOException {
- String nombre, archivo1 = "ATTT.txt";
- double velocidad = 0, velocidades = 0;
- int i, mul = 0, mul1= 20, mul2= 50, mul3 = 150;
- BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
- System.out.print("Nombre: ");
- nombre = br.readLine();
- System.out.print("Cantidad de velocidades: ");
- i = Integer.parseInt(br.readLine());
- try {
- File f1 = new File(archivo1);
- f1.createNewFile();
- } catch (IOException e) {
- System.out.print("Error de lectura.");
- }
- for ( int iii = i; iii>0; iii--){
- System.out.print("Velocidad: ");
- velocidad = Double.parseDouble(br.readLine());
- velocidades = velocidad + velocidades;
- if (velocidad >= 60 && velocidad <= 119){
- mul = mul + mul1;
- }else if(velocidad >= 120 && velocidad <= 159) {
- mul = mul + mul2;
- }else if(velocidad >= 160){
- mul = mul + mul3;
- }
- }
- if (mul > 0){
- System.out.println("Debe: " + mul + " Dolares, multas acumulativas Pagar lo antes posible.");
- }
- try {
- FileWriter fw = new FileWriter(archivo1, true);
- BufferedWriter bw = new BufferedWriter(fw);
- bw.write(Double.toString(velocidad));
- bw.newLine();
- bw.flush();
- FileWriter fe = new FileWriter(archivo1, true);
- BufferedWriter be = new BufferedWriter(fe);
- be.write(Double.toString(mul));
- be.newLine();
- be.flush();
- } catch (IOException e) {
- System.out.println("Problema de lectura-escritura");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement