Java - Codigo Java

 
Vista:

Codigo Java

Publicado por Juan Camilo (1 intervención) el 08/05/2018 16:53:16
HOLA, soy estudiante de ingeniería de sistemas y telecomunicaciones de la ciudad de Pereira, Colombia, he estado haciendo un código para JAVA ya que es mi trabajo para final de semestre y mis compañeros quedaron mal con el trabajo y no hicieron su parte. hice este código pero me tira varios errores quisiera que me ayudaran, mi trabajo es hacer una calculadora que resuelva una ecuación (aX^3+bX^2+cX+d) por división sintética para convertirla en ecuación de 2 grado y poder hacer cuadrática y obtener los 2 resultados posibles.
quisiera que me ayudaran a corregir lo errores o si es posible hacer el código ( se que suena un poco vago pero la verdad no se que mas hacer) he tratado de corregir el código y pues corregí algunos errores pero aun no se que mas hacer.

Adjunto el archivo .txt del codigo que tengo.

este es el código:

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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
private static int Main()
{
 
	System.out.print("ingresar la ecuacion de la forma aX^3+bX^2+cX+d \n");
 
	int a;
	int b;
	int c;
	int d;
	int result = 0;
	int i;
	float result2;
	float result1;
 
	System.out.print("ingrese aX^3 \n");
	String tempVar = ConsoleInput.scanfRead();
	if (tempVar != null)
	{
		a = Integer.parseInt(tempVar);
	}
	System.out.print("ingrese bX^2 \n");
	String tempVar2 = ConsoleInput.scanfRead();
	if (tempVar2 != null)
	{
		b = Integer.parseInt(tempVar2);
	}
	System.out.print("ingrese cX \n"); ////  ,   ;
	String tempVar3 = ConsoleInput.scanfRead();
	if (tempVar3 != null)
	{
		c = Integer.parseInt(tempVar3);
	}
	System.out.print("ingrese d \n");
	String tempVar4 = ConsoleInput.scanfRead();
	if (tempVar4 != null)
	{
		d = Integer.parseInt(tempVar4);
	}
 
	//system("cls");
	for (i = -100;i < 100;i++)
	{
 
		result = a * i;
		result = result + b;
		result = result * i;
		result = result + c;
		result = result * i;
		result = result + d;
 
	if (result == 0)
	{
 
	System.out.printf("(x = %d) \n", i);
	}
 
	}
	system("pause");
	System.out.print("Resultado de la ecuacion general:\n");
 
		if (result1 > -100F,result2 > -100F)
		{
 
 
	   result1 = -b + (Math.cbrt(b * b - (4 * d * c))) / (2 * d); //ecuacion
	   result2 = -b - (Math.cbrt(b * b - (4 * d * c))) / (2 * d);
 
	   //system("pause");
 
	   System.out.printf("x1= %.0lf\n",result1);
 
 
	   System.out.printf("x2= %.0lf\n",result2);
 
		}
		else
		{
 
		System.out.print("ERROR ECUACION NO TIENE RESULTADO�");
		}
											   //  ,   ;
 
 
 
 
}
 
 
package tangible;
 
public final class ConsoleInput
{
	private static boolean goodLastRead = false;
	public static boolean lastReadWasGood()
	{
		return goodLastRead;
	}
 
	public static String readToWhiteSpace(boolean skipLeadingWhiteSpace)
	{
		String input = "";
		char nextChar;
		while (Character.isWhitespace(nextChar = (char)System.in.read()))
		{
			//accumulate leading white space if skipLeadingWhiteSpace is false:
			if (!skipLeadingWhiteSpace)
			{
				input += nextChar;
			}
		}
		//the first non white space character:
		input += nextChar;
 
		//accumulate characters until white space is reached:
		while (!Character.isWhitespace(nextChar = (char)System.in.read()))
		{
			input += nextChar;
		}
 
		goodLastRead = input.length() > 0;
		return input;
	}
 
	public static String scanfRead()
	{
		return scanfRead(null, -1);
	}
 
	public static String scanfRead(String unwantedSequence)
	{
		return scanfRead(unwantedSequence, -1);
	}
 
	public static String scanfRead(String unwantedSequence, int maxFieldLength)
	{
		String input = "";
 
		char nextChar;
		if (unwantedSequence != null)
		{
			nextChar = '\0';
			for (int charIndex = 0; charIndex < unwantedSequence.length(); charIndex++)
			{
				if (Character.isWhitespace(unwantedSequence.charAt(charIndex)))
				{
					//ignore all subsequent white space:
					while (Character.isWhitespace(nextChar = (char)System.in.read()))
					{
					}
				}
				else
				{
					//ensure each character matches the expected character in the sequence:
					nextChar = (char)System.in.read();
					if (nextChar != unwantedSequence.charAt(charIndex))
						return null;
				}
			}
 
			input = (new Character(nextChar)).toString();
			if (maxFieldLength == 1)
				return input;
		}
 
		while (!Character.isWhitespace(nextChar = (char)System.in.read()))
		{
			input += nextChar;
			if (maxFieldLength == input.length())
				return input;
		}
 
		return input;
	}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder