Вы находитесь на странице: 1из 7

Guia 5

Ricardo Yau 8-956-507 Grupo 1IL-121

Dahían Ramírez 20-14-3955

Problema 1

1. Clase: Notas
2. Atributos: Estudiantes, nota1,nota2,nota3,nota4,notlit,notprom;
3. Metodos: int Estudiante, String nombres, int nota1, int nota2, int nota4, char notalit;
Asignar(int nota1, int nota2, int nota3,int nota4)
Promedio()
Notlit()
4. Seudocódigo
clase Notas {

privado entero not1, not2, not3, not4


privado real notprom
privado caracter notlit

publico Asignar(entero nota1, entero nota2, entero nota3, entero nota4){


not1 = nota1
not2 = nota2
not3 = nota3
not4 = nota4
}
publico real Promedio(){
notprom = (not1+not2+not3+not4)/4
retornar notprom
}
publico caracter Notlit(){
Si(notprom > 90){
notlit = 'A'
}
Sino si(notprom > 80 Y notprom < 90){
notlit = 'B'
}
Sino si(notprom > 70 Y notprom < 80){
notlit = 'C'
}
Sino si(notprom > 60 Y notprom < 70){
notlit = 'D'
}
Sino si(notprom <= 60 Y notprom >= 0){
notlit = 'F'
}
sino{
Escribir("Algun error en la entrada de notas")
}
retornar notlit

}
INICIO
entero ests
cadena nombre
entero nota1, nota2, nota3, nota4
entero i
real notaprom
real notalit

Notas not

Escribir("A cuantos estudiantes va a encuestar")


Leer(ests)
para(i = 0; i < ests; i++){
Escribir("Estudiante #”,i+1, “escriba su nombre y sus 4 notas")
Leer(nombre)
Leer(nota1)
Leer(nota2)
Leer(nota3)
Leer(nota4)

not.Asignar(nota1,nota2,nota3,nota4)
notaprom = not.Promedio()
notalit = not.Notlit()

Escribir(nombre,” Su nota promedio es de ”,notaprom,” y literal”,notalit)

FIN
}

5. Codigo en Java

import java.util.Scanner;

public class Notas {

private int not1, not2, not3, not4;


private double notprom;
private char notlit;

public void Asignar(int nota1, int nota2, int nota3, int nota4){
not1 = nota1;
not2 = nota2;
not3 = nota3;
not4 = nota4;

}
public double Promedio(){
notprom = (not1+not2+not3+not4)/4;
return notprom;
}
public char Notlit(){
if(notprom > 90){
notlit = 'A';
}
else if(notprom > 80 && notprom < 90){
notlit = 'B';
}
else if(notprom > 70 && notprom < 80){
notlit = 'C';
}
else if(notprom > 60 && notprom < 70){
notlit = 'D';
}
else if(notprom <= 60 && notprom >= 0){
notlit = 'F';
}
else{
System.out.println("Algun error en la entrada de notas");
}
return notlit;

}
public static void main(String[] args){
int ests;
String nombre;
int nota1, nota2, nota3, nota4;
int i;
double notaprom;
double notalit;

Notas not = new Notas();


Scanner sc = new Scanner(System.in);

System.out.println("A cuantos estudiantes va a encuestar");


ests = sc.nextInt();
for(i = 0; i < ests; i++){
System.out.println("Estudiante #"+(i+1)+"escriba su
nombre y sus 4 notas");
nombre = sc.nextLine();
nota1 = sc.nextInt();
nota2 = sc.nextInt();
nota3 = sc.nextInt();
nota4 = sc.nextInt();

not.Asignar(nota1,nota2,nota3,nota4);
notaprom = not.Promedio();
notalit = not.Notlit();

System.out.println(""+nombre+" Su nota promedio es


de "+notaprom+" y literal"+notalit);

}
}
Problema 2
1. Clase: Estudiantes
2. Atributos: estudiantes, sexo,estatura,peso;
3. Métodos: int estudiantes, int sexo, int sexo, real estatura, real peso;
Asignar(int sexo, real estatura, real peso)
CantEstM()
CantEstF()
PromPesoxM()
PromPesoxF()
PromEstaturaxM()
PromEstaturaxF()

4. Seudocódigo

5. Código en Java
Problema 3
1. Clase
problema3
2. Atributos
Vent1
Vent2
Vent3
Vent4
total

3. Métodos

Real Vent1, Vent2,Vent3,Vent4,total

Int vendedor (entero v)


Void venta (entero vend, real vent)
Void imprimir ventas()
4. Seudocódigo
5. Código en Java
package guia5;

import java.util.Scanner;

public class problema3 {

double vent1=0,vent2=0,vent3=0,vent4=0;
double total=0;

public int Vendedor(int v){


switch(v)
{
case -1: v=-1; break;
case 1: System.out.println("Bienvenido Luis Moran"); v=1; break;
case 2: System.out.println("Bienvenido María Pérez"); v=1; break;
case 3: System.out.println("Bienvenido Luisa Carrión"); v=1; break;
case 4: System.out.println("Bienvenido Juan Medina"); v=1; break;
default: v=0;
}
return v;

}
public void venta(int vend, Double vent)
{
total+=vent;
switch(vend)
{
case 1: vent1+=vent; break;
case 2: vent2+=vent; break;
case 3: vent3+=vent; break;
case 4: vent4+=vent; break;
}

}
public void imprimirventas()
{
System.out.println("aqui van las ventas totales y parciales");
}

public static void main(String args[]) {


Scanner get=new Scanner(System.in);
problema3 caja = new problema3();
double venta;
int vendedor,validar;
String resp;
do
{
System.out.print("Ingrese su còdigo de vendedor o -1 para
salir: ");

vendedor= get.nextInt();
validar=caja.Vendedor(vendedor);
if(validar==0)
{
System.out.println("codigo incorrecto, intente
nuevamente.");
}
else if(validar>0)
{
do
{
System.out.println("Desea agregar una nueva
venta?");
resp=get.nextLine();
if(resp=="s")
{
System.out.println("digite el monto de la
venta");
venta=get.nextDouble();
caja.venta(vendedor,venta);
}
else if (resp=="n")
{
caja.imprimirventas();
}
else {resp="0";}

} while (resp !="n");


}
} while (validar>-1);

}
}

Вам также может понравиться