Skip to content

Instantly share code, notes, and snippets.

@robsonamendonca
Last active April 29, 2023 14:06
Show Gist options
  • Save robsonamendonca/a427326d27f0cbcfd02fd503a7f34bf3 to your computer and use it in GitHub Desktop.
Save robsonamendonca/a427326d27f0cbcfd02fd503a7f34bf3 to your computer and use it in GitHub Desktop.
HDEV - Algoritmos (Desafios) - Media Simples
/******************************************************************************
Problema: Calcular a media de três notas e mostrar esta media.
Algoritmo media
var nota1, nota2, nota3, media de real;
inicio
mostrar “ler a primeira nota”;
ler(nota1);
mostrar “Ler segunda nota”;
ler(nota2);
mostrar “Ler terceira nota”;
ler(nota3);
media <- ( nota1 + nota2 + nota3 ) / 3;
mostrar “A média é” +media;
fim
Teste de mesa
Nota1 <- 6
Nota2 <- 6
Nota2 <- 6
Media <- ( 6 + 6 + 6 )/ 3 = 6;
A média é 6
*******************************************************************************/
// Online IDE - Code Editor, Compiler, Interpreter
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner ent = new Scanner(System.in);
float nota1 , nota2, nota3, media;
// recebe a 1º nota
System.out.print("Digite sua 1ª nota");
nota1 = ent.nextInt();
// recebe a 2º nota
System.out.print("Digite sua 2ª nota");
nota2 = ent.nextInt();
// recebe a 3º nota
System.out.print("Digite sua 3ª nota");
nota3 = ent.nextInt();
media = (nota1 + nota2 + nota3)/ 3;
System.out.println("A media é: " +media);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment