Show Escape Sequences

    CIS355A WEEK 1

    STEP 1: Show Escape Sequences (10 points)

    Write a Java program named ShowEscapeSequences.java that displays the following.

    I really like
    CIS355A
    “Business Application Programming with Lab using JAVA”

    STEP 2: Circle (15 points)

    Write an application called Circle.java that inputs from the user the radius of a circle as an integer and prints the circle’s diameter, circumference, and area. Use the example program and GUI technique message dialog box shown in the Week 1 Lecture.

    STEP 3: PracticeArithmeticOperators (15 points)

    Write an application called PracticeArithmeticOperators.java that asks the user to enter two numbers. The program is to convert these numbers from String to type int and then print in a tabular format the sum, the difference, the product, and the quotient of the two numbers entered. Use the example program shown in the Week 1 Lecture. For example, if the user enters 25 and 5, the following should be displayed.

    CIS355A WEEK 2

    Program files for each of the following three programs:

    Largest
    Palindrome
    Diamond

    STEP 1: Largest

    Write a Java application program called Largest.java that inputs a series of 10 single-digit numbers and determines and prints the largest of the numbers. Except main() method, no other user-defined method is required. Your program should use at least the following three variables:

    STEP 2: Palindrome

    A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554, and 11611. Write an application called Palindrome.java that reads in a five-digit integer and determines whether it is a palindrome. If the number is not five digits long, display an error message dialog indicating the problem to the user. When the user dismisses the error dialog, allow the user to enter a new value.

    STEP 3: Diamond

    Write a program called Diamond.java that uses a method diamondOfAsterisks() that displays a diamond (the row number of a diamond must be odd) of asterisks whose row is specified in an integer parameter row. For example, if row is 7, the method displays the pattern of asterisks at the top of the next page.

    CIS355A WEEK 3

    STEP 1: Cylinder (20 points)

    Create a class called Cylinder.java that contains two double-precision instance variables named radius and height. The class should include a constructor that initializes the radius and height variables. Also, you need a class method named volume() that returns the volume of a Cylinder object. The volume of a cylinder is given by its radius squared times its height times Pi (radius * radius * height * Math.PI). You can either use the value 3.1416 for Pi or use the Java provided value named Math.PI.

    Write a class called CylinderTest.java and declare an array of three Cylinder objects to call the methods you declared in the Cylinder class. Make sure that all class methods are called from main(). Have main() display the value returned by volume() and verify the returned value by hand calculations (paper/pencil). Prompt the user to enter the values for the radius and height of each Cylinder object in the array.

    STEP 2: Date (20 points)

    Create a program called Date.java to perform error-checking on the initial values, for instance: fields month, day, and year. Also, provide a method nextDay() to increment the day by one. The Date object should always remain in a consistent state.

    Write a program called DateTest.java that prompts the user to enter the month, day, and year as numeric values. This program then creates a Date object using the Date class you just created and tests the nextDay() method. This can be done in a loop of 40 iterations: the Date object calls the nextDay() method and prints the date during each iteration of the loop. This loop is to illustrate that the nextDay() method works correctly. Test the following cases:

    CIS355A WEEK 4

    STEP 1: InheritanceTest (20 points)

    Write a program called InheritanceTest.java to support an inheritance hierarchy for class Point-Square-Cube. Use Point as the superclass of the hierarchy. Specify the instance variables and methods for each class. The private variable of Point should be the x-y coordinates. The private data of Square should be the sideLength. The private data of Cube should be depth. Each class must provide applicable accessor, mutator, and toString() methods for manipulating private variables of each corresponding class. In addition, the Square class must provide the area() and perimeter() methods. The Cube must provide the area() and volume() methods.

    Write a program that instantiates objects of your classes, ask the user to enter the value for x, y, and sideLength, test all instance methods and outputs of each object’s perimeter, area, and volume when appropriate.

    DayGui:

    Add individual event handlers to your program so that when a user clicks the Good button, the message “Today is a good day!” appears in a dialog box, and when the Bad button is clicked, the message “I’m having a bad day today!” is displayed. The following tutorial shows you much of the code solution. Feel free to use the tutorial, but make changes so that you are not simply copying the tutorial code for your entire solution. To make this different from the tutorial, change the colors of the buttons and panel. Also, add this application to a tabbed pane along with the program you will complete in the next step, Step 3. The following tutorials will likely be useful as you work to complete this step:

    STEP 3: OfficeAreaCalculator (10 points)

    Write a program called OfficeAreaCalculator.java that displays the following prompts using two label components

    Enter the length of the office:
    Enter the width of the office:

    Have your program accept the user input in two text fields. When a button is clicked, your program should calculate the area of the office and display the area in a text field with a label of Area. This display should be cleared whenever the input text fields receive the focus. A second button should be provided to terminate the application (Exit button).

    The following tutorial shows you much of the code solution. Feel free to use the tutorial, but make changes so that you are not simply copying the tutorial code for your entire solution. To make this different from the tutorial, change the colors of the panel. Also, add this application to the same tabbed pane (see the JTabbedPane tutorial) as the application you built in Step 2, the DayGui application.

    CIS355A WEEK 5

    Program files for the following two programs: GuessGame Text File I/O At the beginning of ALL your programs put the program name, your name, and a brief description of the program. Example: /************************************************************ Program Name: GuessGame Programmers Name: Nana Liu Program Description: This program will play the game “guess the number”, etc… *************************************************************/ How to submit your assignment: The programs MUST have the same names as the assignment title. Each Java source file (*.java) must include a corresponding class file (*.class) program as evidence of success. You must use a Zipped Folder to send your Weekly Assignment to the DropBox. Do not send subfolders within your zipped folder. Place ALL of the .java and .class files for the week into the one zipped folder. The Zip folder should be named: YourLastName Week 5, and this Zip folder will contain all the weekly programming assignments. Put all program source files in a word document with a screen shot of all your program output. L A B S T E P S

    STEP 1:

    GuessGame (20 pts) Write a program GuessGame.java that plays the game “guess the number” as follows: Your program chooses the number to be guessed by selecting an integer at random in the range 1–1000. The program then displays the following in a label:

    I have a number between 1 and 1000 can you guess my number? Please enter your first guess.

    A JTextField should be used to input the guess. As each guess is input, the background color should change to either red or blue. Red indicates that the user is getting “warmer,” and blue indicates that the user is getting “colder.”

    A JLabel should display either “Too High” or “Too Low” to help the user zero in on the correct answer. When the user gets the correct answer, “Correct!” should be displayed, and the JTextField used for input should be changed to be uneditable.

    A JButton should be provided to allow the user to play the game again.

    When the JButton is clicked, a new random number should be generated and the input JTextField changed to be editable.

    STEP 2:

    Text File I/O (20 points) Write a program to create a file named “numbers.dat”. Then create an algorithm that adds all even numbered integers from 1 to 100, separated by a comma. After the file has been created, close and reopen the file and display the results to the screen. After the results have been displayed append the odd number integers from 1 to 100, separated by a comma to the end of the file. Reopen the file and display the results.

    CIS355A WEEK 6

    STEP 1: Index (10 points)

    Write a Java GUI application called Index.java that inputs several lines of text and a search character and uses String method indexOf to determine the number of occurrences of the character in the text. This program is not case sensitive and both upper and lower case must be counted for.

    STEP 2: Index2 (10 points)

    Write a Java GUI application Index2.java based on the program in Step 1 that inputs several lines of text and uses String method indexOf to determine the total number of occurrences of each letter of the alphabet in the text. Uppercase and lowercase letters should be counted together. Store the totals for each letter in an array, and print the values in tabular format after the totals have been determined.

    STEP 3: ThreeArrayLists (20 points)

    Write a program called ThreeArrayLists.java that declares three ArrayList objects referenced by the objects named priceList, quantityList, and amountList. Each ArrayList should be declared in main()and should be capable of holding a minimum of 10 double-precision numbers.

    The numbers that should be stored in priceList are 10.62, 14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, 3.98.
    The numbers that should be stored in quantityList are 4, 8.5, 6, 7.35, 9, 15.3, 3, 5.4, 2.9 4.8.

    Your program should pass object references to these three ArrayList objects to a method named extend(), which should calculate the elements in the amountList ArrayList as the product of the corresponding elements in the priceList and quantityList ArrayList, for example, amountList.add(priceList.get(i) * quantityList.get(i)).

    After extend() has put values into the amountList ArrayList object, create a method that displays the results of all three lists. Appropriate formatting techniques need to be used to produce a formatted output.

                                                                                                                                      Order Now