Fórum converter String em char #566349
09/04/2009
0
public static void main(String[]args){
int x;
int y;
char op;
double res=0;
String grade;
grade = JOptionPane.showInputDialog("Digite um numero:");
x = Integer.parseInt(grade);
grade = JOptionPane.showInputDialog("Digite um numero:");
y = Integer.parseInt(grade);
grade = JOptionPane.showInputDialog("Digite uma operação:");
op = Character.charAt(grade);
switch(op){
case '+' :
res = x+y;
break;
Lucas Soares
Curtir tópico
+ 0Posts
09/04/2009
Everton Barros
char op[]; op = grade.toCharArray();
Gostei + 0
09/04/2009
Lucas Soares
Gostei + 0
09/04/2009
Vagner Planello
Gostei + 0
09/04/2009
Everton Barros
int x;
int y;
char op [];
double res=0;
String grade;
grade = JOptionPane.showInputDialog("Digite um numero:");
x = Integer.parseInt(grade);
grade = JOptionPane.showInputDialog("Digite um numero:");
y = Integer.parseInt(grade);
grade = JOptionPane.showInputDialog("Digite uma operação:");
op = grade.toCharArray();
switch(op[0]){
case '+' :
res = x+y;
break;
}
System.out.println(res);
Gostei + 0
09/04/2009
Carlos Heuberger
char ch = grade.charAt(0);
if (grade.equals("+")) {
// adicao
} else if (grade.equals("*")) {
// multiplicacao
...
} else {
// operacao nao identificada -> erro
}Gostei + 0
09/04/2009
Lucas Soares
Gostei + 0
02/05/2011
Arthur Calazans
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
char urlFalse[] = new char[100];
urlFalse=jTextField1.getText().toCharArray();
jTextField2.setText(""+urlFalse);
}Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)