CS 1073 Introductory Programming
|
This is the (familiar) song:
Ninety-nine bottles of beer on the wall. Ninety-nine bottles of beer. What would happen if one should fall? Ninety-eight bottles of beer on the wall. Ninety-eight bottles of beer on the wall. Ninety-eight bottles of beer. What would happen if one should fall? Ninety-seven bottles of beer on the wall. Ninety-seven bottles of beer on the wall. ... (and so on until) ... zero bottles of beer on the wall.Here is the complete song. The numbers should be spelled out in English, and you must make use of several strings and arrays of strings, as well as making use of functions, all described below.
String[] ones =
{"zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine"};
String[] teens =
{"Zero", "One", "Two", "Three", "Four",
"Five", "Six", "Seven", "Eight", "Nine",
"Ten", "Eleven", "Twelve", "Thirteen", "Fourteen",
"Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
String[] tens =
{"", "Ten", "Twenty", "Thirty", "Forty",
"Fifty", "Sixty", "Seventy", "Eighty", "Ninety"};
String shortB = " bottles of beer.";
String longB = " bottles of beer on the wall.";
String wall = "What would happen if one should fall?";
public String toEnglish(int n) {
// convert n, 0 <= n <= 99, to an English string and return it
}
public void printSong() {
// print the entire song
}
Note: You should use netBeans, though it is permissible to use Java from another source. In netBeans, the simplest way to make up the material to print is to just copy from netBeans (using ctrl-C) and paste into Word or WordPad (using ctrl-V). Then print the resulting document. You can assemble all 5 programs into a single document to print.
In case your program doesn't produce output or doesn't produce the correct output, you should still turn in a listing for part credit.