TravelingSong - Scanner sc = new Scanner(System.in...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // TravelingSong.java Author: Lewis and Loftus // // Solution to Programming Project 3.10. //******************************************************************** / import java.util.Scanner; i public class TravelingSong { //----------------------------------------------------------------- // Prints the first few verses of "100 Bottles of Beer" //----------------------------------------------------------------- public static void main (String[] args) { final int MAX = 100; int numVerses = 0; // number of verses to print
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Scanner sc = new Scanner(System.in); while (numVerses < 1 || numVerses > MAX) { System.out.print ("How many verses (1 to " + MAX + ")? "); numVerses = sc.nextInt(); } int count = MAX; for (int verse = 1; verse <= numVerses; verse++) { System.out.println (count + " bottles of beer on the wall."); System.out.println (count + " bottles of beer."); System.out.println ("If one of those bottles should happen " + "to fall"); count = count - 1; System.out.println (count + " bottles of beer on the wall."); System.out.println (); } } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Ask a homework question - tutors are online