KeeganT

Ch8Ex2 Num

Mar 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. package ch8ex2;
  2.  
  3. public class Num
  4. {
  5.     int w,o,t,h;
  6.     Num(int num)
  7.     {
  8.         this.w=num;
  9.         this.h=w/100;
  10.         this.t=(w-(h*100))/10;
  11.         this.o=w-(h*100)-(t*10);
  12.     }
  13.    
  14.     public void extract(char choice)
  15.     {
  16.         if(choice=='w')System.out.println(this.w);
  17.         if(choice=='o')System.out.println(this.o);
  18.         if(choice=='t')System.out.println(this.t);
  19.         if(choice=='h')System.out.println(this.h);
  20.     }
  21. }
Add Comment
Please, Sign In to add comment