/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Logica;
import java.lang.*;
import javax.swing.JOptionPane;
/* *
* @author microsoft
*/
public class Estudiante {
double not1, not2,not3, porc1, porc2, porc3;
public Estudiante(double not1, double not2, double not3, double porc1, double porc2, double porc3) {
this.not1 = not1;
this.not2 = not2;
this.not3 = not3;
this.porc1 = porc1;
this.porc2 = porc2;
this.porc3 = porc3;
}
public double getNot1() {
return not1;
}
public void setNot1(double not1) {
this.not1 = not1;
}
public double getNot2() {
return not2;
}
public void setNot2(double not2) {
this.not2 = not2;
}
public double getNot3() {
return not3;
}
public void setNot3(double not3) {
this.not3 = not3;
}
public double getPorc1() {
return porc1;
}
public void setPorc1(double porc1) {
this.porc1 = porc1;
}
public double getPorc2() {
return porc2;
}
public void setPorc2(double porc2) {
this.porc2 = porc2;
}
public double getPorc3() {
return porc3;
}
public void setPorc3(double porc3) {
this.porc3 = porc3;
}
public double calculardef ()
{
double sum = ( (getNot1()*getPorc1())/100)+((getNot2()*getPorc2())/100)+((getNot3()*getPorc3())/100);
double def = sum/3;
def=arrastrarnota(def);
return def;
}
public double arrastrarnota (double nota)
{
if(nota<1.75)
nota=1.5;
else if(nota>=1.75 && nota<2.25)
nota=2.0;
else if(nota>=2.25 && nota<2.75)
nota=2.5;
else if(nota>=2.75 && nota<3.25)
nota=3.0;
else if(nota>=3.75 && nota<3.75)
nota=3.5;
else if(nota>=3.75 && nota<4.25)
nota=4.0;
else if(nota>=4.25 && nota<4.65)
nota=4.5;
else
nota=5.0;
return nota;
}
}
PARTE DE PRESENTACION:
/*
* presentcion de las notas
*/
package Presentacion;
import java.lang.*;
import javax.swing.JOptionPane;
import Logica.Estudiante;
/**
*
* jesus suarez
* david loaiza
* 22 feb 2011
*/
public class Formulario {
public static void main(String args [])
{
double totalponderado =100.0;
int numestudiante=Integer.parseInt(JOptionPane.showInputDialog("Digite el número de estudiantes."));
Estudiante obj[]=new Estudiante [numestudiante];
for(int j=0; j< numestudiante;j++)
{
obj[j]=new Estudiante(0.0,0.0,0.0,0.0,0.0,0.0);
}
for(int i=0, j=1; i< numestudiante;j++,i++)
{
//digite porcentajes yu compruba que no sobrepacen 100
JOptionPane.showMessageDialog(null,"digite porcentajes de estudiante # "+j );
do{
obj[i].setPorc1(Double.parseDouble(JOptionPane.showInputDialog(null," Digite porcentaje 1 de 3:")));
}while (obj[i].getPorc1()>totalponderado && obj[i].getPorc1()>=0);
totalponderado-=obj[i].getPorc1();
do{
obj[i].setPorc2(Double.parseDouble(JOptionPane.showInputDialog(null,"Digite porcentaje 2 de 3:")));
}while (obj[i].getPorc2()>totalponderado && obj[i].getPorc2()>=0);
totalponderado-=obj[i].getPorc2();
do{
obj[i].setPorc3(Double.parseDouble(JOptionPane.showInputDialog(null,"Digite porcentaje 3 de 3:")));
}while (obj[i].getPorc3()>totalponderado && obj[i].getPorc3()>=0);
totalponderado-=obj[i].getPorc3();
totalponderado=100.0;
// realiza la escritura de las ntoas con sus respectivas restricciones
JOptionPane.showMessageDialog(null,"digite notas de estudiante # "+j );
do
{
obj[i].setNot1(Double.parseDouble(JOptionPane.showInputDialog(null,"digite nota 1 de 3 :")));
}while(obj[i].getNot1()<0.0 || obj[i].getNot1()>5.0);
do
{
obj[i].setNot2(Double.parseDouble(JOptionPane.showInputDialog(null,"digite nota 2 de 3 :")));
}while(obj[i].getNot2()<0.0||obj[i].getNot2()>5.0);
do
{
obj[i].setNot3(Double.parseDouble(JOptionPane.showInputDialog(null,"digite nota 3 de 3 :")));
}while(obj[i].getNot3()<0.0||obj[i].getNot3()>5.0);
}
//impresion de los datos
for(int i=0, j=1; i< numestudiante;j++,i++)
{
JOptionPane.showMessageDialog(null, "\nnotas del estudiante #" +j+ " \nnota 1 = "+obj[i].getNot1()+ " porcentaje = "+obj[i].getPorc1()+"\n nota 2 = "+obj[i].getNot2()+ " porcentaje = "+obj[i].getPorc2()+"\nnota 3 = "+obj[i].getNot3()+ " porcentaje = "+obj[i].getPorc3()+ "\n definitiva del estudiante : "+ obj[i].calculardef() );
if(obj[i].calculardef()>=3.0)
JOptionPane.showMessageDialog(null,"aprobo");
else
JOptionPane.showMessageDialog(null, "reprobo");
}
}
}
No hay comentarios:
Publicar un comentario