online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
//package P2; import java.io.*; import java.util.GregorianCalendar; import java.io.IOException; //public class Producto2App { public class Main{ public static void main(String[] args){ DB db = new DB(); db.actualizar("p1.txt","p2.txt"); db.close(); } } class DB{ BufferedReader in; PrintWriter out; public void actualizar(String file1, String file2){ try{ in = new BufferedReader(new FileReader(file1)); out = new PrintWriter(new BufferedWriter(new FileWriter(file2))); String linea; linea = in.readLine(); // lee linea por linea String[] s, fechaSplit; int codigo, anio, mes, dia, precio; String descripcion; GregorianCalendar fecha; while(linea != null){ Producto p; s = linea.split("\t"); codigo = Integer.parseInt(s[0]); descripcion = s[1]; precio = Integer.parseInt(s[2]); fechaSplit = s[3].split("/"); anio = Integer.parseInt(fechaSplit[0]); mes = Integer.parseInt(fechaSplit[1]); dia = Integer.parseInt(fechaSplit[2]); fecha = new GregorianCalendar(anio+1, mes, dia); p = new Producto(codigo, descripcion, precio+1, fecha); // crea System.out.println(p.toString()); // imprime out.println(p.toString()); linea = in.readLine(); } }catch (IOException e) { System.out.println("Error al abrir el archivo"); System.out.println(e); } } public void close(){ out.close(); } } class Producto{ int codigo; String descripcion; int precio; GregorianCalendar fecha; GCUtil gc = new GCUtil(); Producto(int codigo, String descripcion, int precio, GregorianCalendar fecha){ this.codigo = codigo; this.descripcion = descripcion; this.precio = precio; this.fecha = fecha; } public String toString(){ return codigo + "\t" + descripcion + "\t" + precio + "\t" + gc.toString(fecha); } } class GCUtil{ public String toString(GregorianCalendar fecha){ return fecha.get(GregorianCalendar.YEAR) + "/" + fecha.get(GregorianCalendar.MONTH) + "/" + fecha.get(GregorianCalendar.DAY_OF_MONTH); } }
0 D0 10 2021/10/2 1 D1 11 2021/10/3 2 D2 12 2021/10/4 3 D3 13 2021/10/5 4 D4 14 2021/10/6 5 D5 15 2021/10/7 6 D6 16 2021/10/8
0 D0 11 2022/10/2 1 D1 12 2022/10/3 2 D2 13 2022/10/4 3 D3 14 2022/10/5 4 D4 15 2022/10/6 5 D5 16 2022/10/7 6 D6 17 2022/10/8

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue