Você está na página 1de 3

1

CURSO PROFISSIONAL TCNICO DE INFORMTICA DE GESTO

LINGUAGENS DE PROGRAMAO 11 ANO


Ficha n3 Exerccios de Reviso (Arrays)

Cdigo (C#)
using
using
using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;

namespace Exer_Revisao_03
{
public partial class Form1 : Form
{
int i,j;
int numalunos = 4;
double[] Notas = new double[10];
string[] Nome = new string[10];
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//Inserir Nomes dos alunos e Classificao
listBox1.Items.Clear();

Pgina 1 de 3

2013/2014

CURSO PROFISSIONAL TCNICO DE INFORMTICA DE GESTO

2013/2014

for (i = 0; i < numalunos; i++)


{
Nome[i] = Convert.ToString(Microsoft.VisualBasic.Interaction.InputBox("Introduza o
Nome", "Alunos", "", 100, 200));
Notas[i] = Convert.ToDouble(Microsoft.VisualBasic.Interaction.InputBox("Introduza a
Classificao", "Notas", "", 100, 200));
int x = i + 1;
listBox1.Items.Add( Nome[i]);

}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//Mostrar Classificao do aluno na Label1
int indice = listBox1.SelectedIndex;
//MessageBox.Show(Convert.ToString(a), "Sair", MessageBoxButtons.OK,
MessageBoxIcon.Information);
label1.Text = Convert.ToString(Notas[indice]);
label5.Text = (Nome[indice]);
}
private void button2_Click(object sender, EventArgs e)
{
//Boto Fechar
if (MessageBox.Show("Sair da Aplicao?", "Sair",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
{
//Application.Exit();
this.Close();
}
}
private void button3_Click(object sender, EventArgs e)
{
//Calcular Mdia
double soma, media;
soma = 0;
for (i = 0; i < numalunos; i++)
{
soma = soma + Notas[i];
}
media = soma / numalunos;
label6.Text = "Mdia: " + Convert.ToString(media);
}
private void button4_Click(object sender, EventArgs e)
{
//Nota mxima
double maximo;
int indice = 0;

Pgina 2 de 3

CURSO PROFISSIONAL TCNICO DE INFORMTICA DE GESTO

2013/2014

maximo = -1;
for (i = 0; i < numalunos; i++)
{
if (Notas[i] > maximo)
{
maximo = Notas[i];
indice = i;
}
}

label6.Text = "Nota Mxima: " + Nome[indice] + " --> " + Convert.ToString(maximo);


}
private void button5_Click(object sender, EventArgs e)
{
//Nota mnima
double minimo;
int indice = 0;
minimo = 100;
for (i = 0; i < numalunos; i++)
{
if (Notas[i] < minimo)
{
minimo = Notas[i];
indice = i;
}
}

label6.Text = "Nota Mmina: " + Nome[indice] + " --> " + Convert.ToString(minimo);


}
}
}

Pgina 3 de 3

Você também pode gostar