Example1:
package While;
public class Police {
public static void main(String[] args) {
int police=0;
int thief=40;
while(police<thief) {
thief=thief+3;
police=police+5;
}
System.out.println(police);
}
}
Output:
100
Example2:
package While;
public class Wrapper {
public static void main(String[] args) {
int choco=15;
int wrapper=15;
while(wrapper>=3) {
wrapper= wrapper-3;
choco=choco+1;
wrapper=wrapper+1;
}
System.out.println(choco);
}
}
Output:
22
Top comments (0)