
Ayuda con un problema de un codigo, Soy un estudiante de universidad no me muestra una lista bien
Publicado por Francisco Javier (1 intervención) el 09/12/2016 18:30:25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import javax.swing.*;
class Matrices
{
public static void main (String[] args)
{
int t,d,c,m[][],x=1,a3,VG=0;
String a1,a2;
m=new int[10][5];
do
{
t=Integer.parseInt(JOptionPane.showInputDialog("Ingrese el numero de tienda (Del 1 al 10)"));
d=Integer.parseInt(JOptionPane.showInputDialog("Ingrese el numero de deporte del articulo (Del 1 al 5)"));
c=Integer.parseInt(JOptionPane.showInputDialog("Ingrese el costo del articulo"));
m[t-1][d-1]=m[t-1][d-1]+c;
x=Integer.parseInt(JOptionPane.showInputDialog("¿Continuar capturando ventas?\n1-Si\n2-No"));
}
while(x==1);
a1=VTT(m,t,d);
a2=VTD(m,t,d);
a3=VG(m,t,d,VG);
JOptionPane.showMessageDialog(null,a1+"\n"+a2+"\nVentas generales "+a3);
}
static String VTT(int m[][], int t, int d )
{ int suma,vs[];
vs=new int[10];
for(int i=0;i<t;i++)
{ suma=0;
for(int j=0;j<d;j++)
suma=suma+m[i][j];
vs[i]=suma;
}
String a1="Ventas por tienda\nTienda Ventas\n";
for(int i=0;i<t;i++)
a1=a1+(i+1)+" "+vs[i]+"\n";
return a1;
}
static String VTD(int m[][], int t, int d)
{ int suma,vs[];
vs=new int[10];
for(int i=0;i<d;i++)
{ suma=0;
for(int j=0;j<t;j++)
suma=suma+m[i][j];
vs[i]=suma;
}
String a2="Ventas por deporte\nDeporte Ventas\n";
for(int i=0;i<d;i++)
a2=a2+(i+1)+" "+vs[i]+"\n";
return a2;
}
static int VG(int m[][], int t, int d, int VG)
{
for(int i=0;i<t;i++)
for(int j=0;j<d;j++)
VG=VG+m[i][j];
return VG;
}
}
Valora esta pregunta


0