Assignment You sank my battleship!! For this assignment you will be creating a modified version of battleship. The game will use an 8 X 8 grid to represent the playing space. • At the beginning of the game the user will be asked to place three ships (Battleship size 4, Destroyer size 3, and Patrol Boat size 2) on the board. The user should indicate the starting position (in terms of row and column) and the direction (horizontal or vertical) that they want to place the ship. You should use the methods PlaceBattleship(), PlaceDestroyer(), and PlacePatrol() to either place the boats on the board or indicate that the ship cannot be placed at that location (either because it goes off the board or overlaps a ship that has already been placed0. • Once all three ships are placed the game begins. The user is prompted to enter a grid coordinate. After each entry the game will indicate whether the players shot resulted in a hit or miss or whether the player already fired at that location. • After each guess the game should display the board from the players perspective with * for unknown space, M for misses, and H for hits. • When all of the locations on a ship have been hit the user should be told “You sank my ______” (use the name of whatever ship they sank). • The game ends when all of the ships have been sunk. The game should tell the user how many guesses it took to sink all three ships (guesses of the same location should only be counted once). will be looking for good program design. Therefore, the program should be broken into useful methods (with appropriate parameters). Most of the work should be done by methods and Main() should be as short as possible. please make sure all guidelines are strictly followed.

Problem Design a class named Person with fields for holding a person's name, address and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the class's fields. Next, design a class named Customer , which inherits from the Person class. The customer class should have a field for a customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write one or more constructors and the appropriate mutator and accessor methods for the class's fields. And last, but not least, is the demo class with added specifications. Be sure to review this so you will meet all specs. TO DO: imports // TO DO: author, date, purpose // TO DO: declare class /* TO DO: declare main TO DO: housekeeping - declare constants, variables, objects, initialization, display splash Walk Through of finished program: Prompt for name. Use the name to instantiate a record with a name value only. Display that record with the default values for the other four fields, e.g. no address given, no telephone given, etc. Prompt for another name, address, telephone, customer number. Prompt "Do you want to be on the mailing list?" Enter 'yes' or 'no'. Use all fields to instantiate a record with all 5 values. Display that record with the values. (Change the first record's address, telephone, customer number and mail list preference.) Prompt "Enter a value for " + first record name + "address: " Prompt "Enter a new value for telephone: " Prompt "Enter a new value for the customer number: ". Prompt "Enter a new value for the mailing list option (yes/no): ". Set the new values in the first record. Display new values of record. Exit program. SPECS 1. The following specifications should be met: • UML design submitted in Word document; shows relationships between classes. Note to student: JGrasp will generate the relationships between your files. It is recommended you use this feature under the FILE menu to generate the relationships and then implement them in your Word file. • .java files submitted from JGrasp or other editor; do not submit .class files (-10 points) • required header comments: @author, date, purpose • logo-welcome screen with author, date, name of app, purpose should be a separate class file and have at least two constructors; one constructor with four params (author, date, appName, purpose) and one constructor with three params (date, appName, purpose) • meets specs as detailed in the stated problem in the book; test data should consist of: o John Smith, 111 VHCC Lane, 111-111-1111, 12345, true o Jane Doe, 222 Upward Road, 222-222-2222, 67899, false o Mary Sullivan, 100 Opportunity Lane, 276-739-2400, true o your information • Person class should have two constructors: one with param name; another constructor with all three params • Customer class should have two constructors: one with with custNum; another with both params • Input Validation: none • program is complete and runs • each line in all files is commented • o constant comments should say how they are used o variable comments should state what the variable holds o initialization comments state why the default value o object comments indicate the use of the object o statement comments indicate the process o logic structure comments indicate what logic is being used o ending curly should indicate the end of the structure o methods should be commented using Javadoc comments style (see Wikipedia, http://en.wikipedia.org/wiki/Javadocs#Example) • string or numeric literals do not appear in the input, process or ouput sections (declared as constants) of the demo • mininal spelling and grammar errors • program compiles (-10 if does not compile) • style and readability • follows format: housekeeping, input, process, output; ensure that output does not occur in process and process does not occur in output sections. • follows format for class file as specified in UML (fields, accessors, mutators, processors) • all methods in both the Person and Customer class should be called by the demo program (Note: this is a practice you should get into when writing classes; it is how the class is error-tested.)

Create a class with a method that accepts a charge account number as its argument. The method should determine whether the number is valid by comparing it to the following list of valid charge account numbers: 5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 8080152, 4562555, 5552012, 5050552, 7825877, 1250255, 1005231, 654231, 3852085, 7576651, 7881200. 4581002 These numbers should be stored in an array or an ArrayList object. Use a sequential search to locate the number passed as an argument. If the number is in the array, the method should return true, indicating the number is valid. If the number is not in the array, the method should return false indicating the number is invalid. Write a program that tests the class by asking the user to enter a charge account number. The program should display a message indicating whether the number is valid or invalid.

Using your knowledge of the college environment, determine the functional dependencies that exist in the following table. After determining the functional dependencies, convert this table to an equivalent collection of tables that are in third normal form. Student (StudentNum, StudentName, NumCredits, AdvisorNum, AdvisorName, DeptNum, DeptName, (CourseNum, Description, Term, Grade) )

Summarize the purpose of views and indexes. Why are indexes and view important to an organization? A web search for relevant articles and information should be employed to assist you in your response. Your response should be a reply to the original message. Your discussion board submission should directly support the information covered in the lesson of the week. Initial Response 1) Your submission should be a paragraph responding to the DBMS related question. Your input will include supporting sentences using the terms, concepts, and theories with the page number or website from the required readings or other material. 2) Each initial response should be a courteous paragraph of at least 250 words containing a topic sentence with good supporting sentences.

ALICE 2.4 Chapter 9 Page 283-4, #8 Game: Pick Up all the Buoys In this game, the player is to pick up seven buoys that are floating in the ocean. The player uses keyboard arrows to steer the sailboat to a buoy using the appropriate event(s). When the sailboat is close enough to a buoy, that buoy is picked up and it rides on the sailboat for the rest of the game. When all seven buoys have been picked up, the game is over. To create the world for the game, use the water template and add a sailboat (Vehicles). Add seven bottles (Objects) and resize them so they realistically look like buoys on the surface of the water. Also, set the texture of the bottles to none and then change their color. To create a fog effect such that the fog increases in the distance, set the world’s fog style to distance, fogNearDistance to zero, and fogFarDistance to 100. To create a sunset effect, choose a red/orange color for the world’s atmosphereColor. The screen capture below shows the sailboat in the distance and two of the buoys floating in the water. Five other buoys are located off to the right in the scene below but are currently out of view of the camera. To animate the floating action of all seven buoys, create a world-level list named allBuoys and add each of the seven buoys to the list. Then create a method named sway. In the sway method, use the allBuoys list to roll all the buoys right and left. Create an event that continues to call sway while the world is running. Create an event that allows the player to steer the boat using the arrow keys. Have the camera follow the sailboat to always keep it in view. To determine when the boat gets close enough to pick up a buoy, create a world-level method named checkIfClose-ToBuoy that checks whether the sailboat is within 3 meters of any one of the buoys in the allBuoys list. Create another method named pickUpBuoy, having an object parameter named whichBuoy. The whichBuoy parameter represents the buoy to be picked up. The picked up buoy should be moved to the back of the boat, where it will ride until the game ends (see picture below). To keep the buoy in place, put some object on the back of the boat. Set its opacity to 0 so that it is not visible to the naked eye. When the sailboat is within 3 meters of any buoy, checkIfCloseToBuoy calls pickUpBuoy. The buoy will move into the container on the boat. To keep the buoy there, change its ‘vehicle’ to the container. Use an event that continuously calls checkIfCloseToBuoy while the world is running. To determine when the game is over, you need a way to know when all the buoys have been picked up. To track the buoys that have been picked up, create a second world-level list, this one named pickedUpBuoys and leave it empty. In the pickUpBuoy method, create a statement that adds the picked up buoy to the pickedUpBuoys list. Create a world-level method named checkIfGameIsOver and call it every time a buoy is picked up. When the size of pickedUpBuoys is equal to seven, the player wins the game and a 3D text object is used to display “You did it!”.

The Double.parseDouble() method requires a String argument, but it fails if the String cannot be converted to a floating-point number. Write an application in which you try accepting a double input from a user and catch a NumberFormatException if one is thrown. The catch block forces the number to 0 and displays an appropriate error message. Following the catch block, display the number.

(#13 on page 670 – 671) Gadgets by Mail sells many interesting items through its catalogs. Write an application that prompts the user for order details, including item numbers and quantity of each item ordered, based on the available items shown in Table 12-2. Table 12-2 Items offered by Gadgets by Mail Item # Description Price ($) 101 Electric hand warmer 12.99 124 Battery-operated plant waterer 7.55 256 Gerbil trimmer 9.99 512 Talking bookmark 6.89 The shipping and handling fee for an order is based on the total order price, as shown in Table 12-3. Table 12-3 Shipping and handling fees charged by Gadgets by Mail Price of Order ($) Shipping and Handling ($) 0–24.99 5.55 25.00–49.99 8.55 50.00 or more 11.55 Create the following classes:  Gadget, which contains an item number, description, and price for a gadget; a constructor that sets all the fields; and get methods to retrieve the field values.  Order, which contains an order number, customer name, and address (assume you need just a street address, not city, state, and zip code); a list of item numbers ordered (up to four); the total price of all items ordered; and a shipping and handling fee for the order. Include a constructor to set the field values and get methods to retrieve the field values. GadgetOrderTaker, which is an interactive application that takes four customer orders. The class contains an array of the four Gadget objects offered (from Table 12-2). The application prompts each user for a name and street address and assigns a unique order number to each customer, starting with 101. The application asks each user to enter an item number and quantity wanted. When the user enters 999 for the item number, the order is complete, and the next customer can enter data. Each customer can order up to four item numbers. When a customer’s order is complete (the customer has entered 999 for an item number, or has ordered four different items), calculate the shipping and handling charges. After four customers have placed Orders, display each Order’s data, including the order number, the name and address of the customer, and the list of items ordered, including the item number, description, and price of each Order, the total price for the order, and the shipping and handling charge. The GadgetOrderTaker class handles all thrown Exceptions by displaying an explanatory message and ending the application.  OrderException, which is an Exception that is created and thrown under any of the following conditions:  A customer attempts to order more than four different items.  A customer orders more than 100 of any item.  A customer enters an invalid item number.  Also, catch the Exception generated by either of these conditions:  A customer enters a nonnumeric character as the item number.  A customer enters a nonnumeric character as the quantity. Save the files as Gadget.java, Order.java, GadgetOrderTaker.java, and OrderException.java.  The GadgetOrderTaker class handles all thrown Exceptions by displaying an explanatory message and ending the application. Create a new application that handles all Exceptions by requiring the user to reenter the offending data. Save the file as GadgetOrderTaker2.java.

Create a text file for this assignment – named products.txt The format of the file is: ProductID, ProductName, ProductPrice, ProductQty The data in the file is as follows: 1. Create a class based on the above file 5 pts 2. Create an application that: Reads the file, creates a Product object and loads the object to a strongly-typed ArrayList 5 pts Process the ArrayList: a) if the product has a qty < 6, write the object to a Reorder ArrayList 5 pts Print Reorder ArrayList with the following format:

Please help write an application in Java that takes, as input, a series of similar images and outputs a new image with unwanted objects from the original series removed. The images will be provided as ppm files so all your program needs to do is edit them as text files to accomplish your goal. I have provided three images attached to this assignment: 1. tetons1.ppm 2. tetons2.ppm 3. tetons3.ppm See if you can guess which objects should be removed from these images. How do you remove the unwanted objects? Notice that the unwanted images appear in different parts of each image. This allows you to simply write a new ppm file where each RGB value will be whatever the majority of the three images above suggest. So in this case at least 2 of the files will always have the right pixel values. So how do you do this in Java? Make a class called Effects. In it go ahead and make a method called filter that takes two explicit parameters: an array of File objects and a String which will be the name of the new file. The method will then write a new file using the majority rules approach described above for each pixel RGB value. Using an array to store the File objects allows the user to provide any number of File objects to the method. So what do you turn in? Along with your ReadMe turn in two files: One called EffectsTest.java and the other called Effects.java. Your main method should be in EffectsTest.java. Have it ask the user for the file names of the input files, instantiate the corresponding File objects and put them in an array. Then instantiate an Effects object. Finally, ask the user for the output file name and use the filter method to create the new image file. Remember your application should work on any number of ppm files, not just the three provided here. Extra Credit (20 points): 1) (15 points) Add a method called "flipHorizontal" to your Effects class which will flip the picture horizontally. That is, the pixel that is on the far right end of the row ends up on the far left of the row and vice versa (remember to preserve RGB order!). Allow the user to test this in your main method. 2) (5 points) Add a method called greyScale which will change the picture into a grey scale image. This is done by averaging the values of all three color numbers for a pixel, the red, green and blue, and then replacing them all by that average. So if the three colors were 25, 75 and 250, the average would be 116, and all three numbers would become 116. NOTE: None of these manipulations may cause a color number to be less than 0 nor larger than the maximum color depth specified in the file (color depth is the number on the third line of the file). Grading Each question in the Programming portion of your assignment will be graded as follows: 20% for whether it compiles 30% for whether it runs properly (expected output for given input, etc.) 20% for style (formatting of code, variable names, comments, etc.) 30% for design (efficiency, handling error conditions, etc.) Please make sure your program at least compiles before you submit it! There will be no partial credit for a program that "almost" compiles.

Summarize the purpose of the SQL language. Compare and contrast using command line SQL and MS Access graphical interface. Describe at least two advantages and two disadvantages with each method. Why do you think it is important to understand both approaches? A web search for relevant articles and information should be employed to assist you in your response. Your response should be a reply to the original message. Your discussion board submission should directly support the information covered in the lesson of the week. Initial Response 1) Your submission should be a paragraph responding to the DBMS related question. Your input will include supporting sentences using the terms, concepts, and theories with the page number or website from the required readings or other material. 2) Each initial response should be a courteous paragraph of at least 250 words containing a topic sentence with good supporting sentences.

1) Develop a Java application that plays a "guess the number" game as described below. a) Your application first gets a random number in the range 1-1000 inclusive (you might want to use Math.random or the Random class). b) The application then displays the following prompt (probably via a JLabel): I have a number between 1 and 1000. Can you guess my number? Please enter your first guess. Post a textbox for the user to enter a number and post a message telling the user to hit 'Enter' after entering a guess in a textbox (probably using a JTextField).

Write a Java application that allows a user to play Blackjack against the computer. The computer will act as the house, dealing the cards and paying when you win. There is a general set of rules along with optional plays for both the player and dealer. For this assignment you will implement just a simple version of the game using the following basic rules: Only one deck is used and it is shuffled after every hand. Dealer hits on 16 or under and stands on all 17s or better. Your application does not include betting nor does it track a player's performance; it simply plays one hand at a time and declares a winner after each hand. As mentioned before, there are many other variations, including splitting, doubling down, surrender possibilities, insurance, and more. Please do not implement any of these rules unless you are attempting the extra credit (see below). Classes: Your application must include the following six classes: BlackJack (the test class), Card, Deck, Player, Dealer, and Game. The BlackJack class and the Card class are complete. Do not change them. For the other four classes I have included partially complete templates to help get you started. NOTE: Your application must use all of these and must work with the BlackJack test class. For maximum points all I/O operations (printing to the monitor and reading from the keyboard) should happen in the Game class or the Player class. For the Aspiring Hacker (20 points of extra credit): Allow the player to buy chips, bet on each hand, and track how much money a player has from hand-to-hand. Here are the specifications for this: § The player must buy-in for at least $100.00. § You must keep track of the player’s funds from hand to hand. § A player must bet between $10.00 and $1000.00 dollars on any hand. § Blackjack pays 1.5 to 1 unless the dealer also has blackjack in which case it’s a push (tie). § Player may double down on any two card hand except blackjack. Grading Each question in the Programming portion of your assignment will be graded as follows: 20% for whether it compiles 30% for whether it runs properly (expected output for given input, etc.) 20% for style (formatting of code, variable names, comments, etc.) 30% for design (efficiency, handling error conditions, etc.) Please make sure your program at least compiles before you submit it! There will be no partial credit for a program that "almost" compiles.

Create a ProductException class whose constructor receives a String that consists of a product number and price. Save the file as ProductException.java. Create a Product class with two fields, productNum and price. The Product constructor requires values for both fields. Upon construction, throw a ProductException if the product number does not consist of three digits, if the price is less than $0.01, or if the price is over $1,000. Save the class as Product.java. Write an application that establishes at least four Product objects with valid and invalid values. Display an appropriate message when a Product object is created successfully and when one is not.

DeVry University Online CIS355A Course Project Guide Business Systems Programming I--Course Project • Project Description • Analysis and Design • User's Manual • Minimum Requirements • Sample Extended Requirements Project Description The importance of a graphical user interface in programming is paramount in being successful in the business industry. This project incorporates GUI techniques with other tools that you have learned about in this class. Here is your assignment: You work for a Landscape architect. They have asked you to be a part of their team as they need a computer programmer, analyst, and designer to aid them in calculating engineering specification. Specifically, you have been assigned to the Pools, Hot Tubs and Spas section of their landscaping team. Your skills will be needed in creating a GUI program that calculates engineering specifications. This assignment is due in Week 7, but it is suggested that you begin working on the course project assignment in Week 5, which should give you ample time to complete the project. You will find that all the lectures, Quick Test Programs, and Lab assignments will prepare you for the course project. Analysis and Design In week 4, you will complete the analysis and design for the project. You will use the information described in Chapter Two (pages 48-49) to create the Analysis and Design documentation. You will create the following items: 1. Request for New Application 2. Problem Analysis 3. List and description of the requirements 4. Interface Storyboard/drawing 5. Design Flowchart or pseudo code The Analysis and Design document will be a single MS Word document, which contains all descriptions and drawings. User's Manual Include a User's Manual: a Word document, with screenshots, that explains how to run your application. Your mark will depend both on the program quality, and the quality of the User's Manual. Here are some more detailed guidelines about the User's Manual: • It does not need to be long, probably not more than 10 pages, including screenshots. • Write it at the expected user's level - not too technical. • Detail all the functionality that the application provides. Best, structure you presentation top-down way. • For each function, show what it its purpose and sample execution, with a screenshot. Minimum Requirements This example would be the bare minimum to obtain a passing grade (no more than a 75%): This Swimming Pool Calculator is one that is very simple to use. As you can see, it is a user interface that will allow the user to enter the desired length, width, and average depth of a pool and the program will calculate the volume of that pool based on the entered information. This information is then stored in a file that can be viewed. The interface contains four text boxes for the user to enter information along with a calculate and an exit button. Entering Length of Pool The user will be able to enter the length of the pool(in feet) in the text box shown above. To enter information in the box, the user must click in the desired box. The curser will appear allowing the user to enter the appropriate information. To get to the next box, all the user needs to do is either click with the mouse the next box, or the user can hit the tab button on their keyboard. Either method will move the cursor to the next input. Entering the Width of the Pool As with the length box, the width box is used in the same fashion. The user will enter the width of the Pool(in feet) using the keyboard. The user will then have the option to move to the next box by either using the mouse and clicking in the average box, or they can use the tab key on their keyboard. Either way will move the cursor to the average depth box. Entering the Average Depth The user will now enter the average depth of the Pool(in feet). This needs to be as exact a measurement as possible. If the user only wants to know an about figure then the measurements do not need to be as accurate. The more accurate the user needs the volume to be, the more accurate the measurements need to be. If a mistake is made, all the user needs to do is click the backspace button on their keyboard and the entered information will be deleted. Calculating the Volume The final step is for the user to calculate the volume of the Pool. This can be done in two ways. First, the user can click the calculate button to calculate the volume of the pool. Second, the user can use their keyboard and press Ctrl+C and the program will calculate the volume. Retrieving Data.Txt file The Data.txt file can be retrieved by going into the workspace file using Windows Explorer. Once there the user can click on the Data file to retrieve the contents. The contents will be in Word pad form, and will look like the following page. From this point, the user can either review the document or can change any information. If the user desired, they could make this document a read only document by going into the security settings in Windows and setting the access. This should only be done by the administrator. Exiting the program To exit the program, the user can do one of two things. First, the user can click on the Exit button. This will close the program. Two, the user can use the keyboard and click Ctrl+X. Third, the user can click on the red X at the top of the interface. Any of these methods will allow the program to close. Below are some hints: …… volume = length * width * depth; //Will calculate the volume of the pool volumeField.setText(num.format(volume)); //Will display the volume of the pool for the user { //Will write to the Data.txt file try{ FileWriter fileW = new FileWriter("Data.txt", true); System.out.println("Writing data to Data.txt file"); fileW.write("length:"); fileW.write(lengthField.getText()); fileW.write(","); fileW.write(" "); fileW.write("width:"); fileW.write(widthField.getText()); fileW.write(","); fileW.write(" "); fileW.write("avg depth:"); fileW.write(depthField.getText()); fileW.write(","); fileW.write(" "); fileW.write("volume:"); fileW.write(volumeField.getText()); fileW.write(","); fileW.close(); FileReader fileR = new FileReader("Data.txt"); BufferedReader buffIn = new BufferedReader(fileR); String textData = buffIn.readLine(); System.out.println(textData); buffIn.close(); System.out.println("\n"); } catch(IOException e1) { JOptionPane.showMessageDialog(null,e1.getMessage(), "ERROR",2); //Will display error message if unable to write to file } } Sample Extended Requirements The following screenshots provide a sample of what is possible, and could lead to a project worth the maximum grade of 100%. Something to think about!!! Do not think this is what you have to do to get the maximum number of points. It is just a sample! You are only bound by your programming ability. Please do not try and do more than you are capable of. Think, plan, design and code YOUR course project. This is your opportunity to show off your skills! General Interface The first panel simply displays today’s date – I opted to not give the user the option to change this, as it uses the system date. Since this is to be a generic tool, we give the user the option to set the company name in the Options tab; doing so will change “Enter a company name in the Options tab” to the company name. An Exit button is provided in all tabs. Mnemonic values are set for all buttons throughout the application. I opted for a few different error-catching options rather than a consistent one throughout the application, just to show some extra functionality. All tabs can easily be set to behave identically. Options tab This tab allows the user to enter a company name. Hitting Set New Name will change the window’s title to whatever was entered. The result: Customers tab General This tab allows the user to add new customers. It will display the existing customers in the main area. Functionality General The program checks for the existence of the customer.txt file in the directory where the program is located. If the file does not exist, the program tells the customer in the Message Area at the bottom. The Customer Display will give a brief explanation of options. Add Customer In this window, the user can enter customers. Again, the Message Area will display program message. The State selection contains a list of all US state abbreviations. No error checking is performed here, as we are dealing with strings – the information will be stored literally as entered. Selecting Add Customer will attempt to write the information to customer.txt. If the file is write-protected, the Message Area will inform the user. If the file does not exist, it is created. If the file already exists and can be written to, the information will be appended to the file. Fields are not emptied when focused on (this can easily be changed). Below is an example of the situation where the file already exists and can be written to; notice the message in the Message Area: The Delete File option gives the user the option to delete the customer.txt file. If the file does not exist, the Message Area will inform the user after Yes has been selected. If No is selected, the Customer File Deletion window simply closes. After a customer has been added and the Customers window is closed, the user selects Refresh to refresh the Customer Display area, which will display the contents of the customer.txt file. It can be changed to automatically refresh the contents, but I preferred to give the user some more control. Contractor tab The Contractor tab functions in exactly the same way as the Customers tab. The file name for contractors is contractor.txt. Pools tab General This tab allows for pool volume calculation. It assumes pools are rectangular (round- and oval-shaped pools/tubs can be calculated in the Hot Tubs tab. Functionality After a length, width, and depth have been entered, the user clicks Calculate Volume and the program will display the calculated volume (length * width * depth in cubic feet). Anomalies caught are no input and invalid input. The user is limited to entering only numbers and periods. No input: Invalid input: Combination invalid input/no input: Hot Tubs tab General This tab allows for round and oval tubs’ volumes to be calculated. Functionality When Round Tub is selected, the user cannot fill out the width field, as it should be the same as the length (since we’re dealing with a circle). After filling out the length and tub fields, the Calculate Volume button will display the volume (Pi * ((length/2)^2) * depth). The width is automatically set to the same value as the length, and the user is informed. Again, invalid input is caught (only numbers and periods are allowed), and the program will display the same error messages as the Pools tab. When Oval Tub is selected, the width field is opened up: Again, the same error messages are displayed in case of no input/invalid values. Formula used is (Pi * (length * width)^2) * depth. Temp Calc tab General This tab offers a temperature converter (Celsius Fahrenheit). Functionality The user enters a temperature, and selects either C or F. The field after the Result display will display the opposite (if C is selected, field will display F; if F is selected, field will display C). I took a different approach for the System Messages here, but the principle is the same. In this tab, the temperature value will be automatically set to zero in case of invalid input or no input. No input: Length Calc tab General This tab offers the user a length converter (millimeters, meters, yards, feet, and inches). Functionality The user fills out one of the fields (only numerical values and the period are allowed), and hits Convert. Only one of the fields can be filled out at any time (changing the focus will delete the other fields). The end… In order to get full credit which is 100 points, you need to provide a lot of extra functionalities. I prepared the following 4 examples to assist you. 1. The JTabbedPane class 2. Checkboxes and radio buttons 3. Lists and combo boxes 4. Scrollbars and sliders The JTabbedPane Class If you've ever dealt with the Control Panel in Windows, you already know what a JTabbedPane is. It's a container with labeled tabs. When you click on a tab, a new set of controls is shown in the body of the JTabbedPane. In Swing, JTabbedPane is simply a specialized container. Each tab has a name. To add a tab to the JTabbedPane, simply call addTab(). You'll need to specify the name of the tab as well as a component that supplies the tab's contents. Typically, it's a container holding other components. Even though the JTabbedPane only shows one set of components at a time, be aware that all the components on all the pages are in memory at one time. If you have components that hog processor time or memory, try to put them into some "sleep" state when they are not showing. The following example create five tabs, each tab have their own components. import java.awt.*; import javax.swing.*; public class TabDemo extends JFrame { public TabDemo() { super( "JTabbedPane Demo " ); JTabbedPane tab = new JTabbedPane(); // constructing the first panel JLabel l1 = new JLabel( "Welcome to CIS355A", SwingConstants.CENTER ); JPanel p1 = new JPanel(); p1.add( l1 ); tab.addTab( "Tab#1", null, p1, " Panel #1" ); // constructing the second panel JLabel l2 = new JLabel("Welcome to JTabbedPaneDemo", SwingConstants.CENTER); JPanel p2 = new JPanel(); p2.setBackground( Color.blue ); p2.add( l2 ); tab.addTab( "Tab#2", null, p2, " Panel #2" ); // constructing the third panel JLabel l3 = new JLabel( " Java is sooooooooooo fun!" ); JPanel p3 = new JPanel(); p3.setLayout( new BorderLayout() ); p3.add( new JButton( "J" ), BorderLayout.NORTH ); p3.add( new JButton( "A" ), BorderLayout.WEST ); p3.add( new JButton( "V" ), BorderLayout.EAST ); p3.add( new JButton( "A" ), BorderLayout.SOUTH ); p3.add( l3, BorderLayout.CENTER ); tab.addTab( "Tab#3", null, p3, " Panel #3" ); // constructing the fourth panel JLabel l4 = new JLabel( "panel four" ); JPanel p4 = new JPanel(); p4.setBackground( Color.black ); JLabel digits = new JLabel( "Java" ); digits.setFont( new Font( "Serif", Font.ITALIC, 50 ) ); digits.setForeground( Color.blue ); p4.add( digits ); tab.addTab( "Tab#4", null, p4, " Panel #4" ); // constructing the last panel JLabel l5 = new JLabel( "panel five" ); JLabel l6 = new JLabel( "The end!" ); JPanel p5 = new JPanel(); p5.add( l6 ); tab.addTab( "Tab#5", null, p5, " Panel #5" ); // add JTabbedPane to container getContentPane().add( tab ); setSize( 250, 200 ); setVisible( true ); } public static void main( String args[] ) { TabDemo demo = new TabDemo(); demo.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } } Checkboxes and Radio Buttons A checkbox is a labeled toggle switch. Each time the user clicks it, its state toggles between checked and unchecked. Swing implements the checkbox as a special kind of button. Radio buttons are similar to checkboxes, but they are normally used in groups. Clicking on one radio button in the group automatically turns the others off. They are named for the mechanical preset buttons on old car radios (like some of us had in high school). Checkboxes and radio buttons are represented by instances of JCheckBox and JRadioButton, respectively. Radio buttons can be tethered together using an instance of another class called ButtonGroup . By now you're probably well into the swing of things (no pun intended) and could easily master these classes on your own. We'll use an example to illustrate a different way of dealing with the state of components and to show off a few more things about containers. A JCheckBox sends ItemEvent s when it's pushed. Because a checkbox is a kind of button, it also fires ActionEvents when checked. For something like a checkbox, we might want to be lazy and check on the state of the buttons only at some later time, such as when the user commits an action. For example, when filling out a form you may only care about the user's choices when the submit button is pressed. DriveThrough prints the results when we press the Place Order button. Therefore, we can ignore all the events generated by our checkboxes and radio buttons and listen only for the action events generated by the regular button. //file: DriveThrough.java import java.awt.*; import java.awt.event.*; import javax.swing.*; public class DriveThrough { public static void main(String[] args) { JFrame frame = new JFrame("Lister v1.0"); JPanel entreePanel = new JPanel( ); final ButtonGroup entreeGroup = new ButtonGroup( ); JRadioButton radioButton; entreePanel.add(radioButton = new JRadioButton("Beef")); radioButton.setActionCommand("Beef"); entreeGroup.add(radioButton); entreePanel.add(radioButton = new JRadioButton("Chicken")); radioButton.setActionCommand("Chicken"); entreeGroup.add(radioButton); entreePanel.add(radioButton = new JRadioButton("Veggie", true)); radioButton.setActionCommand("Veggie"); entreeGroup.add(radioButton); final JPanel condimentsPanel = new JPanel( ); condimentsPanel.add(new JCheckBox("Ketchup")); condimentsPanel.add(new JCheckBox("Mustard")); condimentsPanel.add(new JCheckBox("Pickles")); JPanel orderPanel = new JPanel( ); JButton orderButton = new JButton("Place Order"); orderPanel.add(orderButton); Container content = frame.getContentPane( ); content.setLayout(new GridLayout(3, 1)); content.add(entreePanel); content.add(condimentsPanel); content.add(orderPanel); orderButton.addActionListener(new ActionListener( ) { public void actionPerformed(ActionEvent ae) { String entree = entreeGroup.getSelection( ).getActionCommand( ); System.out.println(entree + " sandwich"); Component[] components = condimentsPanel.getComponents( ); for (int i = 0; i < components.length; i++) { JCheckBox cb = (JCheckBox)components[i]; if (cb.isSelected( )) System.out.println("With " + cb.getText( )); } } }); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.setSize(300, 150); frame.setVisible(true); } } DriveThrough lays out three panels. The radio buttons in the entreePanel are tied together through a ButtonGroup object. We add() the buttons to a ButtonGroup to make them mutually exclusive. The ButtonGroup object is an odd animal. One might expect it to be a container or a component, but it isn't; it's simply a helper object that allows only one RadioButton to be selected at a time. In this example, the button group forces you to choose a beef, chicken, or veggie entree, but not more than one. The condiment choices, which are JCheckBoxes, aren't in a button group, so you can request any combination of ketchup, mustard, and pickles on your sandwich. When the Place Order button is pushed, we receive an ActionEvent in the actionPerformed() method of our inner ActionListener. At this point, we gather the information in the radio buttons and checkboxes and print it. actionPerformed() simply reads the state of the various buttons. We could have saved references to the buttons in a number of ways; this example demonstrates two. First, we find out which entree was selected. To do so, we call the ButtonGroup's getSelection() method. This returns a ButtonModel, upon which we immediately call getActionCommand(). This returns the action command as we set it when we created the radio buttons. The action commands for the buttons are the entrée names, which is exactly what we need. To find which condiments were selected, we use a more complicated procedure. The problem is that condiments aren't mutually exclusive, so we don't have the convenience of a ButtonGroup. Instead, we ask the condiments JPanel for a list of its components. The getComponents() method returns an array of references to the container's child components. We'll use this to loop over the components and print the results. We cast each element of the array back to JCheckBox and call its isSelected() method to see if the checkbox is on or off. If we were dealing with different types of components in the array, we could determine each component's type with the instanceof operator. Or, more generally, we could maintain references to the elements of our form in some explicit way (a map by name,perhaps). Lists and Combo Boxes JLists and JComboBoxes are a step up on the evolutionary chain from JButtons and JLabels. Lists let the user choose from a group of alternatives. They can be configured to force a single selection or allow multiple choices. Usually, only a small group of choices is displayed at a time; a scrollbar lets the user move to the choices that aren't visible. The user can select an item by clicking on it. She can expand the selection to a range of items by holding down Shift and clicking on another item. To make discontinuous selections, the user can hold down the Control key instead of the Shift key (on a Mac, this is the Command key). A combo box is a cross-breed between a text field and a list. It displays a single line of text (possibly with an image) and a downward pointing arrow on one side. If you click on the arrow, the combo box opens up and displays a list of choices. You can select a single choice by clicking on it. After a selection is made, the combo box closes up; the list disappears, and the new selection is shown in the text field. Like other components in Swing, lists and combo boxes have data models that are distinct from visual components. The list also has a selection model that controls how selections may be made on the list data. Lists and combo boxes are similar because they have similar data models. Each is simply an array of acceptable choices. This similarity is reflected in Swing, of course: the type of a JComboBox's data model is a subclass of the type used for a JList's data model. The next example demonstrates this relationship. The following example creates a window with a combo box, a list, and a button. The combo box and the list use the same data model. When you press the button, the program writes out the current set of selected items in the list. Here's the code for the example: //file: Lister.java import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Lister { public static void main(String[] args) { JFrame frame = new JFrame("Lister v1.0"); // create a combo box String [] items = { "uno", "due", "tre", "quattro", "cinque", "sei", "sette", "otto", "nove", "deici", "undici", "dodici" }; JComboBox comboBox = new JComboBox(items); comboBox.setEditable(true); // create a list with the same data model final JList list = new JList(comboBox.getModel( )); // create a button; when it's pressed, print out // the selection in the list JButton button = new JButton("Per favore"); button.addActionListener(new ActionListener( ) { public void actionPerformed(ActionEvent ae) { Object[] selection = list.getSelectedValues( ); System.out.println("-----"); for (int i = 0; i < selection.length; i++) System.out.println(selection[i]); } }); // put the controls the content pane Container c = frame.getContentPane( ); JPanel comboPanel = new JPanel( ); comboPanel.add(comboBox); c.add(comboPanel, BorderLayout.NORTH); c.add(new JScrollPane(list), BorderLayout.CENTER); c.add(button, BorderLayout.SOUTH); frame.setSize(200, 200); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.setVisible(true); } } The combo box is created from an array of strings. This is a convenience—behind the scenes, the JComboBox constructor creates a data model from the strings you supply and sets the JComboBox to use that data model. The list is created using the data model of the combo box. This works because JList expects to use a ListModel for its data model, and the ComboBoxModel used by the JComboBox is a subclass of ListModel. The button's action event handler simply prints out the selected items in the list, which are retrieved with a call to getSelectedValues(). This method actually returns an object array, not a string array. List and combo box items, like many other things in Swing, are not limited to text. You can use images, drawings, or some combination of text and images. You might expect that selecting one item in the combo box would select the same item in the list. In Swing components, selection is controlled by a selection model. The combo box and the list have distinct selection models; after all, you can select only one item from the combo box while it's possible to select multiple items from the list. Thus, while the two components share a data model, they have separate selection models. We've made the combo box editable. By default, it would not be editable: the user could choose only one item in the drop-down list. With an editable combo box, the user can type in a selection, as if it were a text field. Noneditable combo boxes are useful if you just want to offer a limited set of choices; editable combo boxes are handy when you want to accept any input but offer some common choices. There's a great class tucked away in the last example that deserves some recognition. It's JScrollPane. In Lister, you'll notice we created one when we added the List to the main window. JScrollPane simply wraps itself around another Component and provides scrollbars as necessary. The scrollbars show up if the contained Component's preferred size (as returned by getPreferredSize() ) is greater than the size of the JScrollPane itself. The following example combins all the above choice boxes and layout managers in one application – Language. import java.awt.*; import javax.swing.*; public class Language extends JFrame { private JButton button1, button2, button3, button4; private JCheckBox check1, check2, check3, check4; private JRadioButton radio1, radio2, radio3; private ButtonGroup radioGroup; private JComboBox comboBox; private JLabel label1, label2; private JPanel panel1, panel2, panel3, panel4, panel5,panel6, panel7, panel8; public Language() { super( "Language Choice" ); // build left north panel label1 = new JLabel( "My favorite language" ); panel1 = new JPanel(); panel1.setLayout( new FlowLayout( FlowLayout.LEFT ) ); panel1.add( label1 ); // build right east panel button1 = new JButton( "Reset" ); button2 = new JButton( "Clear" ); button3 = new JButton( "Confirm" ); button4 = new JButton( "Help" ); panel2 = new JPanel(); panel2.setLayout( new GridLayout( 4, 1, 5, 5 ) ); panel2.add( button1 ); panel2.add( button2 ); panel2.add( button3 ); panel2.add( button4 ); // build left south panel label2 = new JLabel( "Class " ); comboBox = new JComboBox(); comboBox.addItem( "CIS170" ); comboBox.addItem( "CIS247" ); comboBox.addItem( "CIS355" ); check1 = new JCheckBox( "Currently taking" ); panel3 = new JPanel(); panel3.setLayout( new FlowLayout( FlowLayout.CENTER, 10, 0 ) ); panel3.add( label2 ); panel3.add( comboBox ); panel3.add( check1 ); // build left east panel check2 = new JCheckBox( "C++" ); check3 = new JCheckBox( "C#" ); check4 = new JCheckBox( "Java", true ); panel4 = new JPanel(); panel4.setLayout( new BorderLayout( ) ); panel4.add( check2, BorderLayout.NORTH ); panel4.add( check3, BorderLayout.CENTER ); panel4.add( check4, BorderLayout.SOUTH ); // build left west panel panel5 = new JPanel(); panel5.setLayout( new BorderLayout() ); panel5.add( radio1 = new JRadioButton( "Strongly Recommend",true ), BorderLayout.NORTH ); panel5.add( radio2 = new JRadioButton( "Recommend", false ), BorderLayout.CENTER ); panel5.add( radio3 = new JRadioButton( "Not Recommend", false ), BorderLayout.SOUTH ); // group the radio buttons radioGroup = new ButtonGroup(); radioGroup.add( radio1 ); radioGroup.add( radio2 ); radioGroup.add( radio3 ); // build left center panel8 = new JPanel(); panel8.setLayout( new FlowLayout( FlowLayout.CENTER, 30, 0 ) ); panel8.setBackground( Color.white ); panel8.add( panel4 ); panel8.add( panel5 ); // setup left panel panel6 = new JPanel(); panel6.setLayout( new BorderLayout() ); panel6.add( panel1, BorderLayout.NORTH ); panel6.add( panel8, BorderLayout.CENTER ); panel6.add( panel3, BorderLayout.SOUTH ); // setup layout panel7 = new JPanel(); panel7.setLayout( new FlowLayout( FlowLayout.CENTER, 10, 0 ) ); panel7.add( panel6 ); panel7.add( panel2 ); getContentPane().add( panel7 ); setSize( 500, 160 ); setVisible( true ); } // end constructor public static void main( String args[] ) { Language myChoice = new Language(); myChoice.setDefaultCloseOperation( EXIT_ON_CLOSE ); } } Scrollbars and Sliders JScrollPane is such a handy component that you may not ever need to use scrollbars by themselves. In fact, if you ever do find yourself using a scrollbar by itself, chances are you really want to use another component called a slider. There's not much point in describing the appearance and functionality of scrollbars and sliders. Instead, let's jump right in with an example that includes both components. The following case shows a simple example with both a scrollbar and a slider. //file: Slippery.java import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class Slippery { public static void main(String[] args) { JFrame frame = new JFrame("Slippery v1.0"); Container content = frame.getContentPane( ); JPanel main = new JPanel(new GridLayout(2, 1)); JPanel scrollBarPanel = new JPanel( ); final JScrollBar scrollBar = new JScrollBar(JScrollBar.HORIZONTAL, 0, 48, 0, 255); int height = scrollBar.getPreferredSize( ).height; scrollBar.setPreferredSize(new Dimension(175, height)); scrollBarPanel.add(scrollBar); main.add(scrollBarPanel); JPanel sliderPanel = new JPanel( ); final JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 255, 128); slider.setMajorTickSpacing(48); slider.setMinorTickSpacing(16); slider.setPaintTicks(true); sliderPanel.add(slider); main.add(sliderPanel); content.add(main, BorderLayout.CENTER); final JLabel statusLabel = new JLabel("Welcome to Slippery v1.0"); content.add(statusLabel, BorderLayout.SOUTH); // wire up the event handlers scrollBar.addAdjustmentListener(new AdjustmentListener( ) { public void adjustmentValueChanged(AdjustmentEvent e) { statusLabel.setText("JScrollBar's current value = " + scrollBar.getValue( )); } }); slider.addChangeListener(new ChangeListener( ) { public void stateChanged(ChangeEvent e) { statusLabel.setText("JSlider's current value = " + slider.getValue( )); } }); frame.pack( ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.setVisible(true); } } All we've really done here is added a JScrollBar and a JSlider to our main window. If the user adjusts either of these components, the current value of the component is displayed in a JLabel at the bottom of the window. The JScrollBar and JSlider are both created by specifying an orientation, either HORIZONTAL or VERTICAL. You can also specify the minimum and maximum values for the components, as well as the initial value. The JScrollBar supports one additional parameter, the extent. The extent simply refers to what range of values is represented by the slider within the scroll bar. For example, in a scrollbar that runs from 0 to 255, an extent of 128 means that the slider will be half the width of the scrollable area of the scrollbar. JSlider supports the idea of tick marks, lines drawn at certain values along the slider's length. Major tick marks are slightly larger than minor tick marks. To draw tick marks, just specify an interval for major and minor tick marks, and then paint the tick marks: slider.setMajorTickSpacing(48); slider.setMinorTickSpacing(16); slider.setPaintTicks(true); JSlider also supports labeling the ticks with text strings, using the setLabelTable() method. Responding to events from the two components is straightforward. The JScrollBar sends out AdjustmentEvents every time something happens; the JSlider fires off ChangeEvents when its value changes. In our simple example, we display the new value of the changed component in the JLabel at the bottom of the window. Grading scales of Course Project 1. You will get 75% which is 75 points out of 100 points if you only finished the basic calculation with an appropriate user’s manual. The user’s manual worth 20 points, the program source file worth 55 points. After each calculation, the collected information and the calculated volume will be saved into a file (or database). You will then add a function to retrieve the input and calculation history from the and display it on the screen. 2. You will get 90% which is 90 points out of 100 points if you designed the following GUI with functioning Pool and Spa tab with an appropriate user’s manual. The user’s manual worth 20 points, the program source file worth 70 points. 3. You will get 100% which is 100 point out of 100 points if you designed the following GUI with all five functioning tab which provides capabilities to calculate the volume and add Customer, Vendors and Contractors info with an appropriate user’s manual. The user’s manual worth 20 points, the program source file worth 80 points. The course project is quite challenging, please plan to start early. Happy coding!

Sharing your scoops to your social media accounts is a must to distribute your curated content. Not only will it drive traffic and leads through your content, but it will help show your expertise with your followers.

Integrating your curated content to your website or blog will allow you to increase your website visitors’ engagement, boost SEO and acquire new visitors. By redirecting your social media traffic to your website, Scoop.it will also help you generate more qualified traffic and leads from your curation work.

Distributing your curated content through a newsletter is a great way to nurture and engage your email subscribers will developing your traffic and visibility.
Creating engaging newsletters with your curated content is really easy.