CSC 207 CSC 207.01 & .02- Algorithms and Object-Oriented Design Spring 2022 Home Schedule Class Slides Labs Assignments Resources Lab: Java Review This lab presents a variety of Java programs for you to write. It will not give detailed, step-wise instructions. You must read the prompts and apply what you know about computer programming in general, object-oriented design/programing in particular, and general problem-solving and testing approaches. Silly Song Use methods to decompose this silly, little song into appropriate sections for each verse and the repeated lines that appear after new each verse. Print the song to standard output. Iteration In the recursion lab, we calculated the Fibonacci numbers recursively. It is also frequently tackled as an interative project. Write a program that will calculate and print the first 12 Fibonacci numbers iteratively. Strings and StringBuilder Write a method called printReverse that accepts a string as its parameter. It should print the characters in the opposite order. Do not use the String or StringBuilder class reverse() methods. Loops, Conditionals, and Random Numbers Write a program that will play "Guess My Number" with the user. The computer should generate a pseudo-random number between 1 and 100. Then it should prompt the user to guess the number. After each guess, the computer should tell the user if the target (random) number is higher, lower, or equal to the guessed number. If the user guesses the number, congratulate them and end the program. Give the user a limited number of guesses. Most people can guess the number in between 5 and 10 guesses. Reading from a File and Command-Line Arguments We often write papers for classes or publication that have a minimum or maximum word count. Counting the words in a long paper is a tedious task, and many word processing programs have a feature that will do this for us. Write a program that takes the name of a file from the command line, opens it, and counts the total number of words and sentences. Assume that words (including "words" comprised of numerals or special characters) are separated by white space and that sentences end in punctuation(periods, exclamation marks, and question marks). You do not need to handle special cases such as abbreviations. Print the results to the console. Don't forget to handle possible exceptions and close the file properly. Recursion Find the factorial of a number using recursion and print the result to the screen. Generics Review the syntax for generic static methods as well as for generic non-static methods. Many of our labs have used generic classes, such as the Generics lab from earlier this semester. Take some time to review this lab. Use a data structure such as the Java Library Stack class to: Determine if an expression's parenthesis and braces are balanced Determine if a work is a palindrome Convert a base 10 number to a binary number (assume that it is a postive integer) Acknowledgements Some exercises in this review are adapted from the Weiss textbook and Reges & Stepp's Building Java Programs For More Practice I recommend that you set aside some time over the summer to continue to practice writing programs in all of the languages you currently know. HackerRank.com has a wide variety of problems to solve, and you generally may choose the programming language you want to practice with. This derivative work is used and licensed under a Creative Commons Attribution-NonCommercialShareAlike 4.0 International license. This course is adapted from prior courses taught by Shervin Hajiamini, John Stone, Sam Rebelsky, Anya Vostinar, and Jerod Weinman and used by permission. Other authors' contributions are noted when used or adapted.