Skip to content

Instantly share code, notes, and snippets.

@FernandaBernardo
Created March 16, 2013 15:05
Show Gist options
  • Save FernandaBernardo/5176765 to your computer and use it in GitHub Desktop.
Save FernandaBernardo/5176765 to your computer and use it in GitHub Desktop.
/*
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