| 
	
		|  Autor | Tema: Duda con JOptionPane;  :(   (Leído 8,010 veces) |  
	| 
			| 
					
						| rub'n 
								       
								
								 Desconectado 
								Mensajes: 1.223
								
								 
								(e ->  λ("live now")); tatuar -> λ("α");
								
								
								
								
								
								     | 
 
no entiendo xq me da error ,,creo que me falta un String ... :S de verdad no c si agregar un String mas para que me ande ,,,  sin la JOptionPane   si la puedo hacer . saluD.o.S...   *Escribir un programa que solicite ingresar 10 notas de alumnos y nos informe cuántos  * tienen notas mayores o iguales a 7 y cuántos menores. */ import javax.swing.JOptionPane;public class While1{ 	public static void main(String [] rubn){   		int notas;		int contador=1;		int mayor=0;		int menor=0;   		while( contador <= 10)		{						snotas=JOptionPane .showInputDialog(null ,"Introduce notas ");   			if(notas >= 7   ) 			{				 mayor++;			} 			if(notas < 7) 			{				menor++;			} 			contador++; 		}   		JOptionPane.showMessageDialog(null ,"los alumnos con notas mayores a 7: "+  mayor); 		JOptionPane.showMessageDialog(null ,"los alumnos con notas menores a 7: "+  menor);      } }  
 
 |  
						| 
								|  |  
								| « Última modificación:  1 Noviembre 2010, 05:12 am por RuB'n. » |  En línea | 
 
 If you don't have time to read, you don't have the time (or the tools) to write, Simple as that. Stephen king |  |  |  | 
			| 
					
						| Shell Root | 
 
import javax.swing.JOptionPane;public class While1{	public static void main(String[]  args){  		while(i <= 5){						Notas = JOptionPane .showInputDialog(null ,"Introduce notas "); 			if(sNotas >= 7){				sMayor++;			}else if(sNotas < 7){				sMenor++;			}			i++;						} 		JOptionPane.showMessageDialog(null , "los alumnos con notas mayores a 7: "+  sMayor);		JOptionPane.showMessageDialog(null , "los alumnos con notas menores a 7: "+  sMenor);  }}
 o hasta directamente sin necesidad de usar una variable String para recibir el valor de las notas 
 
 
 |  
						| 
								|  |  
								| « Última modificación: 25 Octubre 2010, 03:29 am por Shell Root » |  En línea | 
 
 Te vendería mi talento por poder dormir tranquilo. |  |  |  | 
			| 
					
						| rub'n 
								       
								
								 Desconectado 
								Mensajes: 1.223
								
								 
								(e ->  λ("live now")); tatuar -> λ("α");
								
								
								
								
								
								     | 
 
gracias alex , (MODIFICADO) NO IMPORTA,,,mira pero xq le quitas el 
 System.exit(0);  ???  ,,,y disculpa pero es que todavia no me he metido con POO
 |  
						| 
								|  |  
								| « Última modificación: 25 Octubre 2010, 03:37 am por RuB'n. » |  En línea | 
 
 If you don't have time to read, you don't have the time (or the tools) to write, Simple as that. Stephen king |  |  |  | 
			| 
					
						| Shell Root | 
 
Eso no tiene nada que ver con POO!. mmm a ver decidme para que os pusisteis eso? Creo que estais en WIN$? |  
						| 
								|  |  
								|  |  En línea | 
 
 Te vendería mi talento por poder dormir tranquilo. |  |  |  | 
			| 
					
						| rub'n 
								       
								
								 Desconectado 
								Mensajes: 1.223
								
								 
								(e ->  λ("live now")); tatuar -> λ("α");
								
								
								
								
								
								     | 
 
ahh  ya entendi era que me faltaba esto String snotas="" ;    ,,,explicamelo porfa  te lo agradezco        osea tenia que pornerlo bien ,,,        pero xq es eso asi ?? no c  |  
						| 
								|  |  
								| « Última modificación: 25 Octubre 2010, 03:47 am por RuB'n. » |  En línea | 
 
 If you don't have time to read, you don't have the time (or the tools) to write, Simple as that. Stephen king |  |  |  | 
			| 
					
						| Shell Root | 
 
La verdad no te entendí lo anterior, y no era por eso tú error. Eso es solo una variable, |  
						| 
								|  |  
								|  |  En línea | 
 
 Te vendería mi talento por poder dormir tranquilo. |  |  |  | 
			| 
					
						| rub'n 
								       
								
								 Desconectado 
								Mensajes: 1.223
								
								 
								(e ->  λ("live now")); tatuar -> λ("α");
								
								
								
								
								
								     | 
 
entonces cual fue mi error ?     |  
						| 
								|  |  
								|  |  En línea | 
 
 If you don't have time to read, you don't have the time (or the tools) to write, Simple as that. Stephen king |  |  |  | 
			| 
					
						| jdc | 
 
El error fue que el showinputdialog recibe stríng, sí te fijas ahí en el código arreglado lo parsea a integer que es lo que estas usando tu. |  
						| 
								|  |  
								|  |  En línea | 
 
 |  |  |  | 
			| 
					
						| Shell Root | 
 
@jdc, WTF! Eso no fue jejejejejejejejjejejejejjejejeje |  
						| 
								|  |  
								|  |  En línea | 
 
 Te vendería mi talento por poder dormir tranquilo. |  |  |  | 
			| 
					
						| jdc | 
 
xD lo siento, mucho tequila, además vi el código desde el cel jajaja |  
						| 
								|  |  
								|  |  En línea | 
 
 |  |  |  |  |  
 
	
 
 
				
					
						| Mensajes similares |  
						|  | Asunto | Iniciado por | Respuestas | Vistas | Último mensaje |  
						|   |   | Problema con JoptionPane Java
 | monsefoster | 2 | 4,447 |  17 Abril 2011, 19:38 pm por monsefoster
 |  
						|   |   | se puede heredar de JOptionPane ?? Java
 | jhonatanAsm | 4 | 4,000 |  3 Febrero 2012, 14:39 pm por jhonatanAsm
 |  
						|   |   | joptionpane con botones. Java
 | josco | 1 | 4,205 |  20 Septiembre 2012, 18:07 pm por sapito169
 |  
						|   |   | Problemas con JOptionPane.YES_NO_OPTION Java
 | BJM | 1 | 2,677 |  28 Octubre 2013, 23:07 pm por Mitsu
 |  
						|   |   | cajero con JOptionPane Java
 | daniloops | 0 | 3,164 |  23 Junio 2014, 22:12 pm por daniloops
 |    |