SHARE
TWEET

Untitled

a guest Jun 15th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ParImpar {
  2.  
  3. public int totali;
  4. public int totalp;
  5.  
  6. public ParImpar(int totali, int totalp) {
  7.     this.totali = totali;
  8.     this.totalp = totalp;
  9. }
  10.  
  11. public static void main(String[] args) {
  12.     new ParImpar(0,1).parImpar();
  13.     //System.out.println(new ParImpar(0, 1).totalp);
  14. }
  15.  
  16. public void parImpar(){
  17.     for (int i = 0; i < 101; i++) {
  18.         if ((i % 2) != 0){
  19.             totali = totali + i;
  20.             System.out.println(totalp);
  21.         }else{
  22.             totalp = totalp * i;
  23.         }
  24.     }
  25.     System.out.println("Total pares " + totalp);
  26.     System.out.println("Total impar " + totali);
  27. }}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top