Worksheet 1.2
Worksheet 1.2
1 In the main() method, declare and integer variable x. Using a loop, print a countdown from x
to 0.
2 public class forLoop {
3
4 public static void main(String[] args) {
5
6 for(int i=10; i>=0; i-=2) {
7 System.out.println(i);
8 }
9 System.out.println("Happy new Years");
b) Another method that prints the current age of a student when given the year of birth.