Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fp04;
- import java.io.*;
- import java.util.*;
- import java.math.*;
- /**
- *
- * @author aluno
- */
- public class FP04 {
- public static void main(String[] args) throws IOException {
- int n, i, r;
- double d;
- Contador neg, pos;
- neg = new Contador();
- pos = new Contador();
- System.out.println("Introduza um numero:");
- Scanner teclado = new Scanner(System.in);
- n = teclado.nextInt();
- for(i=1; i<=n; i++){
- d = Math.random();
- r = (int)(d*200 - 100);
- if(r<0)
- neg.incConta();
- else
- pos.incConta();
- }
- System.out.println("Positivos:" + pos + "\n" + "Negativos:" + neg);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement