Dicho esto, que excepción intentas capturar con ese try catch?
Yo creo que en la variable int se guardara el valor numérico de la tabla ASCII y no dará excepción, pero no estoy seguro de ello. Cual es la excepción que quieres capturar?
public boolean hasNext():
Finds and returns the next complete token from this scanner. A complete token is preceded and followed by input that matches the delimiter pattern. This method may block while waiting for input to scan, even if a previous invocation of hasNext() returned true.public boolean hasNextInt()
Returns true if the next token in this scanner's input can be interpreted as an int value in the default radix using the nextInt() method. The scanner does not advance past any input.ves lo facil que es en matlab yo no lo usaria para
resolver algo tan simple como eso, deberian abrir un subforo de matlab y yo podria ser moderador matlab es muy facil yo hice un programa en matlab que
resuelve todos los casos de factorizacion exepto factor comun y por agrupacion, fue muy facil, reto a alguien a que lo haga en java para comparar cuantas lineas
le salen en java resolviendo los casos de factorizacion haber si java lo hace mas rapido que matlab no creo
con matlab tambien se pueden hacer aplicaciones graficas y es muy util, si crees que con java se puede hacer caulquier cosa intenta sacar todos los casos de factorizacion en java hasta los que aparecen en wikipedia, intenta sacar factorizacion por division sintetica y el caso de pitagoras yo lo hice en matlab y fue muy facil
con matlab tambien se pueden hacer aplicaciones graficas y es muy util, si crees que con java se puede hacer caulquier cosa intenta sacar todos los casos de factorizacion en java hasta los que aparecen en wikipedia, intenta sacar factorizacion por division sintetica y el caso de pitagoras yo lo hice en matlab y fue muy facil
por ejemplo investigando un poco sobre robots humanoides me di cuenta que todos se pueden programar con matlab
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class BotonesApplet extends Applet implements ActionListener{
Label l1, l2, l3;
TextField t1,t2, t3;
Button b1,b2, b3, b4, b5, b6, b7, b8, b9;
private double Integer;
public BotonesApplet(){
l1= new Label("Numero 1");
t1= new TextField (8);
l2= new Label ("Numero 2");
t2= new TextField(8);
b1= new Button ("Suma");
b2= new Button ("Resta");
b3= new Button ("Multiplica");
b4= new Button ("Divide");
b5= new Button ("Raiz de 1");
b6= new Button ("Raiz de 2");
b7= new Button ("Mayor");
b8= new Button ("Limpia");
b9= new Button ("Menor");
l3= new Label ("Resultado");
t3= new TextField (8);
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
add(b6);
add(b7);
add(b8);
add(b9);
add(l3);
add(t3);
b1. addActionListener(this);
b2. addActionListener(this);
b3. addActionListener(this);
b4. addActionListener(this);
b5. addActionListener(this);
b6. addActionListener(this);
b7. addActionListener(this);
b8. addActionListener(this);
b9. addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == b1) {
double Numero1 = Double.parseDouble(t1.getText());
double Numero2 = Double.parseDouble(t2.getText());
t3.setText(""+Math.abs(Numero1+Numero2));
}
if (ae.getSource() == b2) {
double Numero1 = Double.parseDouble(t1.getText());
double Numero2 = Double.parseDouble(t2.getText());
if (Numero1<Numero2)
t3.setText(""+-Math.abs(Numero1-Numero2));
else
t3.setText(""+Math.abs(Numero1-Numero2));
}
if (ae.getSource() == b3) {
double Numero1 = Double.parseDouble(t1.getText());
double Numero2 = Double.parseDouble(t2.getText());
t3.setText(""+Math.abs(Numero1*Numero2));
}
if (ae.getSource() == b4) {
float Numero1 = Float.parseFloat(t1.getText());
float Numero2 = Float.parseFloat(t2.getText());
t3.setText(""+Math.abs(Numero1/Numero2));
}
if (ae.getSource() == b5) {
double Numero1 = Double.parseDouble(t1.getText());
double Numero2 = Double.parseDouble(t2.getText());
t3.setText(""+Math.sqrt(Numero1));
}
if (ae.getSource() == b6) {
double Numero1 = Double.parseDouble(t1.getText());
double Numero2 = Double.parseDouble(t2.getText());
t3.setText(""+Math.sqrt(Numero2));
}
if (ae.getSource() == b7) {
double Numero1 = Double.parseDouble(t1.getText());
double Numero2 = Double.parseDouble(t2.getText());
if (Numero1>Numero2)
t3.setText(""+Numero1);
if (Numero2>Numero1)
t3.setText(""+Numero2);
}
if (ae.getSource() == b9) {
double Numero1 = Double.parseDouble(t1.getText());
double Numero2 = Double.parseDouble(t2.getText());
if (Numero1<Numero2)
t3.setText(""+Numero1);
if (Numero2<Numero1)
t3.setText(""+Numero2);
}
if (ae.getSource() == b8) {
t1.setText("");
t2.setText("");
t3.setText("");
}}}
espero le sirva a alguien
package trinomio;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class trinomio extends Applet implements ActionListener{
Label l1, l2, l3, l4, l5;
TextField t1,t2, t3, t4, t5;
Button b1;
private double Integer;
public trinomio(){
l1= new Label("a");
t1= new TextField (4);
l2= new Label("b");
t2= new TextField (4);
l3= new Label("c");
t3= new TextField (4);
b1= new Button ("calcula");
l4= new Label("Raiz 1");
t4= new TextField (8);
l5= new Label("Raiz 2");
t5= new TextField (8);
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(b1);
add(l4);
add(t4);
add(l5);
add(t5);
b1. addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == b1) {
double a = Double.parseDouble(t1.getText());
double b = Double.parseDouble(t2.getText());
double c = Double.parseDouble(t3.getText());
int d = (int) (b*b-4*a*c);
int e = (int) Math.sqrt(d);
int f= (int) (2*a);
int g = (int) (-b+e);
int h = -g/f;
int i = (int) (-b-e);
int j = -i/f;
t4.setText(""+Math.abs(+h));
t5.setText(""+-Math.abs(+j));
}
}
private int sqrt(double d) {
// TODO Auto-generated method stub
return 0;
}}
y el segundo y no vayan a decir que es el mismo porque los tengo en carpetas diferentes alguna cosa deben tener distinta pero no me acuerdo package trinomio2;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class trinomio extends Applet implements ActionListener{
Label l1, l2, l3, l4, l5;
TextField t1,t2, t3, t4, t5;
Button b1;
private double Integer;
public trinomio(){
l1= new Label("a");
t1= new TextField (4);
l2= new Label("b");
t2= new TextField (4);
l3= new Label("c");
t3= new TextField (4);
b1= new Button ("calcula");
l4= new Label("Raiz 1");
t4= new TextField (8);
l5= new Label("Raiz 2");
t5= new TextField (8);
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(b1);
add(l4);
add(t4);
add(l5);
add(t5);
b1. addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == b1) {
double a = Double.parseDouble(t1.getText());
double b = Double.parseDouble(t2.getText());
double c = Double.parseDouble(t3.getText());
int d = (int) (b*b-4*a*c);
int e = (int) Math.sqrt(d);
int f= (int) (2*a);
int g = (int) (-b+e);
int h = -g/f;
int i = (int) (-b-e);
int j = -i/f;
t4.setText(""+Math.abs(+h));
t5.setText(""+-Math.abs(+j));
}
}
private int sqrt(double d) {
// TODO Auto-generated method stub
return 0;
}}
aunque les va a parecer que es el mismo si son dos dieferentes que hice para aprobar un curso online la diferencia debe ser pequeñisima pero yo se que deben tener alguna diferencia
C:\Users\XXXXXXXXX\Desktop>fc a.txt b.txt
Comparando archivos a.txt y B.TXT
***** a.txt
package trinomio2;
import java.awt.*;
***** B.TXT
package trinomio;
import java.awt.*;
*****