Guest User

Untitled

a guest
Jan 4th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. public class Puzzle4b
  2. {
  3.     public static void main (string [] args)
  4.     {
  5.         Puzzle4b[] obs = new Puzzle4b[6];
  6.         int y = 1;
  7.         int x = 0;
  8.         int result = 0;
  9.  
  10.         while (x<6)
  11.         {
  12.             obs[x]=new Puzzle4b();
  13.             obs[x].ivar=y;
  14.             y=y*10;
  15.             x=x+1;
  16.         }
  17.  
  18.         x=6
  19.  
  20.         while (x>0)
  21.         {
  22.             x=x-1;
  23.             result = result + obs[x].dostuff(x);
  24.         }
  25.  
  26.         System.out.println("result" +result);
  27.     }
  28. }
  29.  
  30. class Puzzle4b
  31. {
  32.     int ivar;
  33.     public int doStuff(int factor)
  34.     {
  35.         if (ivar >100)
  36.         {
  37.             return ivar*factor;
  38.         }
  39.         else
  40.         {
  41.             return ivar * (5-factor);
  42.         }
  43.     }
  44. }
Add Comment
Please, Sign In to add comment