Está en la página 1de 4

Ejercicio 01 20/05/19

clase:
package javaapplication238;

/**
*
* @author Alumno
*/
public class Cuadrado {
private int lado;
private String nombre;

Cuadrado(int lax,String nomx){

this.nombre = nomx;
this.lado =lax;

public int getLado() {


return lado;
}

/**
* @param lado the lado to set
*/
public void setLado(int lado) {
this.lado = lado;
}
public void Area(){
int s;
s=lado*lado;
System.out.println("El area es: "+s);
}
public void Perimetro(){
int p;
p=lado*4;
System.out.println("El perimetro es: "+p);
}

/**
* @return the nombre
*/
public String getNombre() {
return nombre;
}

/**
* @param nombre the nombre to set
*/
public void setNombre(String nombre) {
this.nombre = nombre;
}
}
main:
public static void main(String[] args) {
int l;
Scanner sc = new Scanner(System.in);
System.out.println("Ingrese lado");
l=sc.nextInt();
System.out.println("Ingrese nombre");
String nom =sc.next();
Cuadrado cuacua = new Cuadrado(l,nom);
cuacua.getLado();
cuacua.Area();
cuacua.Perimetro();

}
Ejercicio 2
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication238;

/**
*
* @author Alumno
*/
public class alumno {
private String nombre;
private String apellido;
private int notaP;
private int notaF;
private int notaPP;
alumno(String nomx,String apelx,int n1,int n2,int n3){

this.nombre = nomx;
this.apellido = apelx;
this.notaP = n1;
this.notaF = n2;
this.notaPP = n3;
}
public int Promedio (){
int prom;
prom=(notaP+notaF+notaPP)/3;
return prom;
}

/**
* @return the nombre
*/
public String getNombre() {
return nombre;
}

/**
* @param nombre the nombre to set
*/
public void setNombre(String nombre) {
this.nombre = nombre;
}

/**
* @return the apellido
*/
public String getApellido() {
return apellido;
}

/**
* @param apellido the apellido to set
*/
public void setApellido(String apellido) {
this.apellido = apellido;
}

/**
* @return the notaP
*/
public int getNotaP() {
return notaP;
}

/**
* @param notaP the notaP to set
*/
public void setNotaP(int notaP) {
this.notaP = notaP;
}

/**
* @return the notaF
*/
public int getNotaF() {
return notaF;
}

/**
* @param notaF the notaF to set
*/
public void setNotaF(int notaF) {
this.notaF = notaF;
}

/**
* @return the notaPP
*/
public int getNotaPP() {
return notaPP;
}

/**
* @param notaPP the notaPP to set
*/
public void setNotaPP(int notaPP) {
this.notaPP = notaPP;
}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication238;

import java.util.ArrayList;
import java.util.Scanner;

/**
*
* @author Alumno
*/
public class JavaApplication238 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int np,nf,npp,p[];
String nom,apel;
ArrayList<alumno> clasePro = new ArrayList<alumno>();
Scanner sc = new Scanner(System.in);
for(int i=0;i<3;i++){

System.out.print("Ingrese nombre: ");


nom =sc.next();
System.out.print("Ingrese apellido: ");
apel =sc.next();
System.out.print("Ingrese notaP: ");
np=sc.nextInt();
System.out.print("Ingrese notaF: ");
nf=sc.nextInt();
System.out.print("Ingrese notaPP: ");
npp=sc.nextInt();
alumno alumnox = new alumno(nom,apel,np,nf,npp);
clasePro.add(alumnox);
// p[i] = alumnox.Promedio();
}
for(alumno x : clasePro){
if(x.Promedio()>=10){
System.out.println(x.getNombre());
System.out.println(x.getApellido());
}
//i++;
}

}
}

También podría gustarte