/* * Copyright (c) 2001 Matthew Feldt. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided the copyright notice above is * retained. * * THIS SOFTWARE IS PROVIDED ''AS IS'' AND WITHOUT ANY EXPRESSED OR * IMPLIED WARRANTIES. */ /** * Count.java * * Java Examples In A Nutshell Copyright (c) 2000 David Flanagan * Exercise 1-1: * Write a program that counts from 1 to 15, printing out each number, and then * count backwards by twos back to 1, again printing out each number. * * @author Matthew Feldt * @version 1.0 */ package com.feldt.examples.basics; import java.lang.*; class Count { public static void main(String[] args) { final int CEILING = 15; int i; System.out.println("Counting from 1 to " + CEILING + ":"); for (i = 1; i <= CEILING; i++) { System.out.println(i); } System.out.println(); System.out.println("Counting backwards by twos from " + CEILING + " to 1:"); for (i = CEILING; i >= 1; i -= 2) { System.out.println(i); } } }