Created
March 16, 2013 15:05
-
-
Save FernandaBernardo/5176765 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
/* | |
A partir da quantidade de homens e de mulheres de uma sala de SI digitada pelo usuário, calcule o percentual (separadamente) de homens e mulheres desta turma. | |
*/ | |
import java.util.Scanner; | |
class Problema1 { | |
public static void main (String [] args) { | |
System.out.println("digite o numero de homens"); | |
Scanner sc=new Scanner(System.in); | |
int homens = sc.nextInt(); | |
System.out.println("Digite o numero de mulheres:"); | |
int mulheres = sc.nextInt(); | |
double total = homens + mulheres; | |
double p1 = homens/total; | |
double p2 = mulheres/total; | |
System.out.println ("Porcentagem de homens:"+ (p1* 100)+"% \nporcentagem de mulheres: " + (p2*100)+"%"); | |
System.out.printf("%.3f",p1*100); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment