Está en la página 1de 3

2) Diseñar en UML e implementar una clase que dadas las tres notas parciales de un curso,

permita calcular la definitiva tomando en consideración los siguientes criterios:

a) Promedio de las tres notas

b) 30%, 30% y 40%

c) 35%, 35% y 30%

d) 25%, 40% y 35%

Solución:

a) Diseño UML
TNotas
-float Nota1;
-float Nota2;
-float Nota3;
+TNOTAS( );
+void setNota1(float N1)
+void setNota2(float N2)
+void setNota3(float N3)
+float getNota1( );
+float getNota2( );
+float getNota3( );
+float Promedio( );
+float Def303040( );
+float Def353530( );
+float Def254035( );

b) Implementación clase TNotas (TNotas.java)

Public class TNotas{


Private float Nota1;
Private float Nota2;
Private float Nota3;

Public TNotas(){
Nota1=0;
Nota2=0;
Nota3=0;
}
Public void setNota1(float N1){
Nota=N1;
}
Public void setNota2(float N2){
Nota=N2;
}
Public void setNota3(float N3){
Nota=N3;
}
Public float getNota1(){
Return Nota1;
}
Public float getNota2(){
Return Nota2;
}
Public float getNota3(){
Return Nota3;
}
Public float Promedio(){
Return (Nota1+Nota2+Nota3)/3;
}
Public float Def303040(){
Return 0.3f*(Nota1+Nota2)+0.4f*Nota3;
}
Public float Def353530(){
Return 35*(Nota1Nota2)/100+30*Nota3/100;
}
Public float Def254035(){
Return (25*Notas+40*Notas2+35*Nota3)/100;
}
}
c) Implementación de clase principal (Digamos que esta clase se llama ejemplo 2)

Import java.util.Scanner;
Public class ejemplo2{

Public static void main(String arg[]){


TNotas Nt;
Scanner lectura;
Float n1,n2,n3;
Nt=new TNotas ();
Lectura
EJERCICIO 1:

1)Diseñar en UML e implementar en java una clase que permita obtener el precio de un
boleto para un partido de futbol considerando que existen las graderías occidental ,
oriental, norte y sur. Se considera un descuento de 30% para menores de 12 años; además
las mujeres tienen un descuento del 10% independiente de su edad.

SOLUCIÓN:
a) DISEÑO UML

TBoleto
-int Precio();
-String gradería();
-byte Edad();
-char Sexo();
+TBoleto();
+void setPrecio(int pre);
+void setGraderia(string gra);
+void setEdad(byte edad);
+void setSexo(char sx);
+int getPrecio();
+string getGraderia();
+byte getEdad();
+char getSexo();
+float DescuentoEdad();
+float DescuentoMujer();
+float Descuento();
+float ValorEntrada();

b) CREAR UN NUEVO PROYECTO


(Aplicación java)
Nombre: EJERCICIO1
Clase principal: PRINCIPAL 1

c) CREAR NUEVA CLASE – Nombre:TBoleto

También podría gustarte