Generation

generate functionTue, 11 Apr 2023

Declarar un tipo de dato array para almacenar notas, un subprograma para poder leer esas notas, otro para escribir las notas, otro que permita caluclar la nota media y todo en un programa principal.

package com.company; import java.util.Scanner; public class Main { public static void main(String[] args) { // write your code here Scanner sc = new Scanner(System.in); int numeroNotas = 0; int[] notas; do { System.out.println("Introduce el numero de notas"); numeroNotas = sc.nextInt(); sc.nextLine(); if (numeroNotas <= 0) { System.out.println("Error, el numero de notas debe ser mayor a 0"); } } while (numeroNotas <= 0); notas = new int[numeroNotas]; for (int i = 0; i < notas.length; i++) { System.out.print("Introduce la nota " + (i + 1) + " :"); notas[i] = sc.nextInt(); sc.nextLine(); } System.out.println("

Questions about programming?Chat with your personal AI assistant