Valeu pessoal…consigui fazer…o que vcs acham?
[code]import javax.swing.*;
public class Media
{
public static void main (String[]args)
{
String st, nome;
double nota1 = 0, nota2 = 0, nota3 = 0, nota4 = 0, media;
while (true)
{
nome = JOptionPane.showInputDialog(null, "Informe seu nome!", "Informe", 3);
if (nome == null) System.exit(0);
nome = nome.trim();
if (nome.length () >=1 && nome.length() <=20) break;
else
{
JOptionPane.showMessageDialog(null, "Informe um nome de 1 a 20 caracteres","Erro",0);
}
}
while (true)
{
st = JOptionPane.showInputDialog(null, "Informe a nota do 1° bimestre!", "Informe",3);
if (st == null) System.exit(0);
try
{
nota1 = Double.parseDouble (st);
if (nota1 >=0 && nota1 <=100) break;
else
{
JOptionPane.showMessageDialog(null, "A nota deve ser de 0 a 100!", "Erro",0);
}
}
catch(NumberFormatException nfe)
{
JOptionPane.showMessageDialog(null,"A nota só deve conter numeros!", "Erro",0);
}
}
while (true)
{
st = JOptionPane.showInputDialog(null, "Informe a nota do 2° bimestre!", "Informe",3);
if (st == null) System.exit(0);
try
{
nota2 = Double.parseDouble (st);
if (nota2 >=0 && nota2 <=100) break;
else
{
JOptionPane.showMessageDialog(null, "A nota deve ser de 0 a 100!", "Erro",0);
}
}
catch(NumberFormatException nfe)
{
JOptionPane.showMessageDialog(null,"A nota só deve conter numeros!", "Erro",0);
}
}
while (true)
{
st = JOptionPane.showInputDialog(null, "Informe a nota do 3° bimestre!", "Informe",3);
if (st == null) System.exit(0);
try
{
nota3 = Double.parseDouble (st);
if (nota3 >=0 && nota3 <=100) break;
else
{
JOptionPane.showMessageDialog(null, "A nota deve ser de 0 a 100!", "Erro",0);
}
}
catch(NumberFormatException nfe)
{
JOptionPane.showMessageDialog(null,"A nota só deve conter numeros!", "Erro",0);
}
}
while (true)
{
st = JOptionPane.showInputDialog(null, "Informe a nota do 4° bimestre!", "Informe",3);
if (st == null) System.exit(0);
try
{
nota4 = Double.parseDouble (st);
if (nota4 >=0 && nota4 <=100) break;
else
{
JOptionPane.showMessageDialog(null, "A nota deve ser de 0 a 100!", "Erro",0);
}
}
catch(NumberFormatException nfe)
{
JOptionPane.showMessageDialog(null,"A nota só deve conter numeros!", "Erro",0);
}
}
media = ((nota1 + nota2 + nota3 + nota4) / 4);
if (media >= 70){
st = ("Parabéns Você Foi Aprovado");
}
if (media == 100){
st = ("Nota maxima");
}
if (media < 70){
st = ("Reprovado");
}
JOptionPane.showMessageDialog(null, "A soma das notas foi: " + (nota1 + nota2 + nota3 + nota4),"Soma",2);
JOptionPane.showMessageDialog(null, nome + " Sua media foi " + media + "\n" + st,"Media",2);
System.exit(0);
}
}[/code]