[Solved] Assignment 6: Fancy Timer

30 $

SKU: [Solved] Assignment 6: Fancy Timer Category: Tag:

Assignment 6: Fancy Timer

IntroductionYou will write two programs: The rst program will display any digit from 0-9 in a fancy way. Thesecond program will be a countdown timer. You may work alone or in pairs for this assignment.In this assignment, you should write a javadoc comment at the top of each class and each method.You will need to write external documentation for the second program.1 Fancy digitsIn this part of the assignment, you will write a program called Fancy.java which displays a fancyversion of the input digit.1.1 Speci cationsInput: The program should accept as input: a single digit (as an int) { the user should be prompted until the number entered is asingle digit, however, you do not need to handle non-integer input a display character or sequence (as a String)Output: A fancy version of the digit, composed of the display character or sequence.Displaying fancy digits: If your display sequence is “*”, then here is what each of your fancydigits should look like:* ***** ***** * * ***** ***** ***** ***** ***** ****** * * * * * * * * * * * * ** ***** ***** ***** ***** ***** * ***** ***** * ** * * * * * * * * * * * ** ***** ***** * ***** ***** * ***** ***** *****Note that you will only need to print one digit at a time, not all on the same line. Theyare displayed here on the same line just to save space.If you look carefully at the digits, you will realize the following facts:1Assignment 6: Fancy TimerCPSC 1150-006/007, Fall 2016Instructor: Adina GoldbergLangara College1. Each fancy digit is made by printing ve lines.2. Each fancy digit is ve characters wide.3. There are only four possible types of lines that can make up a digit:(a) One * on the left, followed by four spaces.(b) Four spaces, followed by one * on the right.(c) One * on the left, followed by three spaces, followed by one * on the right.(d) A row of ve *s.Using methods: You must design and use the following methods to solve the problem. You willinvoke printDigit from main. Within each method, you will need to invoke some of theother methods. A method to print a fancy version of any digit:{ public static void printDigit (int digitToPrint, String disp) { displaysa fancy version of digitToPrint, using the display sequence disp A display method for each of the ten digits:{ public static void printZero (String disp) { displays a fancy version of thedigit 0, using the display sequence disp{ methods for digits 1-8 . . .{ public static void printNine (String disp) { displays a fancy version of thedigit 9, using the display sequence disp Four methods to display each type of line a digit may be composed of:{ public static void printLeft(String disp) { if disp is “*”, prints “* ”{ public static void printRight(String disp) { if disp is “*”, prints ” *”{ public static void printLR(String disp) { if disp is “*”, prints “* *”{ public static void printRow(String disp) { if disp is “*”, prints “*****” Method to generate spaces that match the length of disp:{ public static String getSpaces(int n, String disp) { returns a String com-prised of n * disp.length() spaces1.2 Sample outputSample 1Please enter a digit to display:6Please enter a display character or String:$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$

Sample 2Please enter a digit to display:4Please enter a display character or String:44 44 44444444Sample 3Please enter a digit to display:2Please enter a display character or String:HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello2 Countdown timerYou will write a program called Timer.java. You may write all your code in the main method. Donot rewrite the code needed to print fancy digits. You will need to use the methods you de nedearlier in Fancy.java. As long as both java les are stored in the same directory, you may invoke theprintDigit method inside your Timer program by typing Fancy.printDigit. The other methodscan be invoked in the same way.You will also need to write formal external documentation for this program. Youmay follow the example from class.2.1 Speci cationsInput: The program should accept a number of seconds from the user, and a display String.Output: The program should announce the beginning of the countdown. Then, once per sec-ond, it should display the remaining number of seconds, as a normal integer. However { if theremaining number of seconds is less than ten, display the fancy version of the digit instead!2.2 Sample outputPlease enter a number of seconds to count down:14Please enter a character or String to use in displaying the numbers:%Beginning countdown!1413121110%%%%%% %%%%%%%%%%%%%%%%%% %%%%%%% %%%%%%%%%%%%%%%4Assignment 6: Fancy TimerCPSC 1150-006/007, Fall 2016//And all the fancy digits in between. And then. . .%%%%%%%%%%% %% %% %%%%%%SubmissionRecall that submission instructions are in the Lab Guide. Your group is required to submit one.zip folder (in one person’s D2L dropbox) containing: the internally documented and properly styled source code les:{ Fancy.java{ Timer.java external documentation for the Timer programIf you are working in a group of two, the le should contain both of your names in the header.Make sure both partners save copies of the nished code to their personal H: drive.5

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Assignment 6: Fancy Timer
30 $