C sharp - convertir de java a c#

 
Vista:

convertir de java a c#

Publicado por brandon (1 intervención) el 28/04/2021 22:11:05
Foros aprenderaprogramar.com
Aprender a programar => Aprender a programar desde cero => Mensaje iniciado por: joe en 25 de Noviembre 2016, 21:33
Título: Código crear programa java notas estudiantes con menú y permita obtener promedio
Publicado por: joe en 25 de Noviembre 2016, 21:33
Hola, estoy intentando resolver este problema

Crear un programa en java el cual guarde nombre , sexo , edad , y 5 notas de estudiantes . El programa debe mostrar un menú el cual le pedirá al usuario que desea realizar ( registrar estudiante , consultar estudiante , registrar notas , modificar notas . calcular promedio por cada estudiante si la nota es mayor a 12 puntos decir que esta aprobado de lo contrario esta reprobado decir cual es el estudiante con mayor promedio y con menor promedio , salir ) finalmente nos preguntara si deseamos realizar otra operación .


Código:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import java.util.*;
 
public class Notas_Alumnos {
 
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String[] nombre = new String[10];
		int[] nota1 = new int[10];
		int[] nota2 = new int[10];
		int[] nota3 = new int[10];
		int[] nota4 = new int[10];
		int[] nota5 = new int[10];
		int[] edad = new int[10];
		int[] cedula = new int[10];
		String[] sexo = new String[10];
		int x=0,y,z,resp1;
		String resp2;
		do{
			do{
		System.out.println("Registro de Alumno");
		System.out.println("Seleccione una opción:");
		System.out.println("1 - Registro");
		System.out.println("2 - Consultar");
		System.out.println("3 - Modificar");
		resp1 = s.nextInt();
			}while(resp1<1||resp1>3);
 
		if(resp1==1){
			if(x==10){
				System.out.println("Máximo de alumnos registrados");
			}
			do{
			System.out.print("Ingrese el nombre del alumno "+(x+1)+": ");
			nombre[x] = s.next();
			System.out.print("Ingrese la cedula del alumno "+(x+1)+": ");
			cedula[x] = s.nextInt();
			System.out.print("Ingrese la edad del alumno "+(x+1)+": ");
			edad[x] = s.nextInt();
			System.out.print("Ingrese sexo del alumno "+(x+1)+": ");
			sexo[x] = s.next();
			System.out.print("Ingrese la nota 1 del alumno "+(x+1)+": ");
			nota1[x] = s.nextInt();
			System.out.print("Ingrese la nota 2 del alumno "+(x+1)+": ");
			nota2[x] = s.nextInt();
			System.out.print("Ingrese la nota 3 del alumno "+(x+1)+": ");
			nota3[x] = s.nextInt();
			System.out.print("Ingrese la nota 4 del alumno "+(x+1)+": ");
			nota4[x] = s.nextInt();
			System.out.print("Ingrese la nota 5 del alumno "+(x+1)+": ");
			nota5[x] = s.nextInt();
			x++;
			do{
			System.out.println("¿Desea registrar otro alumno?");
			System.out.println("1 - si");
			System.out.println("2 - no");
			}while(resp1<1||resp1>2);
			resp1 = s.nextInt();
			}while(resp1==1);
		}
 
		if(resp1==3){
			if(x<=0){
				System.out.println("No existen alumnos registrados");
			}
			do{
			System.out.println("Ingrese nombre del alumno que desea consultar: ");
			resp1 = s.nextInt();
			for(int i=0;i<10;i++){
				if(resp1==cedula[i]){
					System.out.println("Nombre del alumno: "+nombre[(i+1)]);
					System.out.println("Edad del alumno: "+edad[(i+1)]);
					System.out.println("Sexo del alumno: "+sexo[(i+1)]);
					System.out.println("Nota 1 del alumno: "+nota1[(i+1)]);
					System.out.println("Nota 2 del alumno: "+nota2[(i+1)]);
					System.out.println("Nota 3 del alumno: "+nota3[(i+1)]);
					System.out.println("Nota 4 del alumno: "+nota4[(i+1)]);
					System.out.println("Nota 5 del alumno: "+nota5[(i+1)]);
				}
			}
				do{
					System.out.println("¿Desea consultar otro alumno?");
					System.out.println("1 - si");
					System.out.println("2 - no");
					resp1 = s.nextInt();
					}while(resp1<1||resp1>2);
					}while(resp1==1);
		}
 
 
		do{
		System.out.println("¿Desea realizar alguna otra operación?");
		System.out.println("1 - si");
		System.out.println("2 - no");
		resp1 = s.nextInt();
		}while(resp1<1||resp1>2);
		}while(resp1==1);
	}

Título: Re:quien me ayuda con esto
Publicado por: ESOJ en 26 de Noviembre 2016, 13:34
Buenos días.
La verdad no entendí muy bien el enunciado.No se si pide la nota de 5 estudiantes o si pide 5 notas de cada estudiante.

Aquí tienes una posible solución con una sola nota por estudiante:

Código:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import java.util.*;
public class Alumno {
    private int idAlumno;
    private String nombre;
    private String sexo;
    private int edad;
    private Double nota;
    private String calificacion;
    public Alumno(int idAlumno, String nombre,String sexo,int edad,Double nota) {
        this.idAlumno = idAlumno;   this.nombre = nombre;    this.sexo=sexo;
        this.edad=edad; this.nota=nota;}
 
    public void setNota(Double nota){this.nota=nota;}
    public void setCalificacion(String calificacion){this.calificacion=calificacion;}
    @Override
    public String toString() { return "ID Alumno: "+idAlumno+" Nombre: "+nombre+" Sexo: "+sexo+" Edad: "+edad+" Nota: "+nota+"  "+calificacion+"\n";  }
  }


Código:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.util.*;
 
public class Programa  {
    public static void main (String []args)      {
        List<Alumno> cjsp = new ArrayList<Alumno>();
        Scanner entradaTeclado = new Scanner(System.in);
        String respuesta;
        int i=1;
        do{
            String calificacion="Suspendido";
            System.out.println("Registro de Alumnos \n");
            System.out.println("Seleccione una opción:");
            System.out.println("1 - Registrar un alumno ");
            System.out.println("2 - Consultar un alumno ");
            System.out.println("3 - Modificar notas ");
            System.out.println("4 - Ver clase completa ");
            System.out.println("5 - Salir ");
            respuesta = entradaTeclado.next();
            switch (respuesta){
                case "1":
                System.out.println("Nombre de alumno");
                String nombre = entradaTeclado.next();
                System.out.println("Sexo del alumno");
                String sexo = entradaTeclado.next();
                System.out.println("Edad del alumno");
                int edad = entradaTeclado.nextInt();
                System.out.println("Nota del alumno");
                Double nota = entradaTeclado.nextDouble();
                if (nota>=12){calificacion="Aprobado";
                }
                Alumno p = new Alumno(i,nombre,sexo,edad,nota);
                p.setCalificacion(calificacion);
                cjsp.add(p);
                i++;
                respuesta="0";
                break;
                case "2":
                System.out.println("Introduce la id del alumno a consultar :");
                int id = entradaTeclado.nextInt();
                if (cjsp.size()<id){System.out.println("Hay "+cjsp.size()+" alumnos registrados");
                }else{System.out.println(cjsp.get(id-1));}
                respuesta="0";
                break;
                case "3":
                System.out.println("Introduce la id del alumno a modificar :");
                id = entradaTeclado.nextInt();
                if (cjsp.size()<id){System.out.println("Hay "+cjsp.size()+" alumnos registrados");
                }else{
                    System.out.println(cjsp.get(id-1));
                    System.out.println("Escribe la nueva nota");
                    Double nuevaNota=entradaTeclado.nextDouble();
                    if (nuevaNota>=12){calificacion="Aprobado";
                    }
                    cjsp.get(id-1).setNota(nuevaNota);
                    cjsp.get(id-1).setCalificacion(calificacion);
                    System.out.println(cjsp.get(id-1));
                }
                respuesta="0";
                break;
                case "4":
                System.out.println("Alumnos en la clase: \n"+cjsp);
                respuesta="0";
                break;
                case "5":
                System.out.println("Adios");
                respuesta="1";
                break;
                default:
                System.out.println("Opción invalida.Debes elegir 1,2,3,4 ó 5");
                respuesta="0";
            }
        }while (respuesta=="0");
    }
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 326
Plata
Ha mantenido su posición en C sharp (en relación al último mes)
Gráfica de C sharp

convertir de java a c#

Publicado por Miguel (143 intervenciones) el 28/04/2021 23:48:31
Java y c# son muy similares

intenta moviendo las primeras funciones y agrega el error que te salga.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar