-
-
Save folivetti/ea3d9323baeb1367262e833969569e37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.util.Scanner; | |
public class Main { | |
public static double arredonda(double x, int casas) { | |
double pot10 = Math.pow(10, casas); | |
return Math.floor(x*pot10) / pot10; | |
} | |
public static void main(String[] args) throws IOException { | |
double N1, N2, N3, N4, E; | |
double media; | |
Scanner sc = new Scanner(System.in); | |
N1 = sc.nextDouble(); | |
N2 = sc.nextDouble(); | |
N3 = sc.nextDouble(); | |
N4 = sc.nextDouble(); | |
media = (2*N1 + 3*N2 + 4*N3 + N4)/10; | |
media = arredonda(media, 1); | |
System.out.printf("Media: %.1f\n", media); | |
if (media >= 7) { | |
System.out.println("Aluno aprovado."); | |
} else if (media < 5) { | |
System.out.println("Aluno reprovado."); | |
} else { | |
System.out.println("Aluno em exame."); | |
E = sc.nextDouble(); | |
System.out.printf("Nota do exame: %.1f\n", E); | |
media = (E + media)/2; | |
if (media >= 5) { | |
System.out.println("Aluno aprovado."); | |
} else { | |
System.out.println("Aluno reprovado."); | |
} | |
System.out.printf("Media final: %.1f\n", media); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment