Java

Need Help in Java Assignment?
We can help you if you are having difficulty with your Java Assignment. Just email your Java Assignment at admin@assignmentcache.com.
We provide help for students all over the world in Java Assignment.

Items 31 to 40 of 110 total

per page
Page:
  1. 2
  2. 3
  3. 4
  4. 5
  5. 6

Grid  List 

Set Ascending Direction
  1. Introduction To Java 9th Edition Chapter 22 Exercise 13 The 24-point game Success

    Introduction To Java 9th Edition Chapter 22 Exercise 13 The 24-point game

    Regular Price: $25.00

    Special Price: $20.00

    Introduction To Java 9th Edition Chapter 22 Exercise 13 The 24-point game


    (Game: the 24-point card game) The 24-point game is to pick any 4 cards from 52 cards, as shown in Figure 22.19. Note that the Jokers are excluded. Each card represents a number. An Ace, King, Queen, and Jack represent 1, 13, 12, and 11, respectively. You can click the Refresh button to get four cards. Enter an expression that uses the four numbers from the four selected cards. Each number must be used once and only once. You can use the operators (addition, subtraction, multiplication, and division) and parentheses in the expression. The expression must evaluate to 24. After entering the expression, click the Verify button to check whether the numbers in the expression are currently selected and whether the result of the expression is correct. Display the verification in a dialog box. Assume that images are stored in files named 1.png, 2.png, . . . , 52.png, in the order of spades, hearts, diamonds, and clubs. So, the first 13 images are for spades 1, 2, 3, . . . , and 13.

    Learn More
  2. Introduction To Java 9th Edition Chapter 25 Exercise 17 Radix sort animation

    Introduction To Java 9th Edition Chapter 25 Exercise 17 Radix sort animation

    Regular Price: $25.00

    Special Price: $20.00

    Introduction To Java 9th Edition Chapter 25 Exercise 17 Radix sort animation

    Write a Java applet that animates the radix sort algorithm. Create an array that consists of 20 random numbers from 0 to 1,000. The array elements are displayed, as shown in Figure 25.19. Clicking the Step button causes the program to place a number in a bucket. The number that has just been placed is displayed in red. Once all the numbers are placed in the buckets, clicking the Step button collects all the numbers from the buckets and moves them back to the array. When the algorithm is finished, clicking the Step button displays a dialog box to inform the user. Clicking the Reset button creates a new random array for a new start.

    Learn More
  3. CIS355A Week 5 Practice Program Pizza FileIO

    CIS355A Week 5 Practice Program - Pizza File/IO

    Regular Price: $12.00

    Special Price: $10.00

    CIS355A Week 5 Practice Program - Pizza File/IO


    Class in this week's practice program, we are "stepping up our game" a bit and we are going to begin seeing a more complex, but more "real world" object oriented program structure, using a 3-tiered (business, presentation, data layer). The good news is that for the Pizza Practice program you are not going to start from scratch, and everything you are being asked to do in this program is demonstrated in the example Circle program.
    If you have any questions or need any help post a question in the Programming/Practice Help discussion in the Introductions and resource module.
    Start by downloading the attached "Week5_Pizza_FileIO_Shell.zip" program, unzip the program and open it up into Netbeans. The shell project will compile and execute, and even read a stream file and populate the list with data from a string file.


    Steps
    You are then asked to complete the following TODO action items:
    Review the FileStream Class and:
    1. in the readlist method add the statements to add a string to the array list
    2. in the writeData method add the statement to write the string to the file
    Review the PizzaFileIO class and:
    1. In the writeData method add code to add the missing order fields to the record
    2. In the readData method add code to add the missing fields to the order object
    Review the OrderList class
    1. In the remove method add statements to remove the order from the list
    2. In the save method add the statement to write the array list to the file.
    Graphical User Interface
    Update the given graphical user interface to:
    1. Save the list in the Order list to a file using both types of file I/O (streams and objects).
    2. Retrieve the list from the file and display the list
    3. Add a menu items Save Orders and Retrieve Orders
    4. Update retrieveOrders method to retrieve the list from the orderList object.
    See the following for a demonstration of the working program.


    Just a Hint
    The amount of code you actually have to write in this execises is no more than 20 lines of code and each TODO can be accomplished with a single line of code.

    Learn More
  4. CIS355A Week 6 Practice Program Pizza DataIO Java

    CIS355A Week 6 Practice Program - Pizza Data/IO

    Regular Price: $12.00

    Special Price: $10.00

    CIS355A Week 6 Practice Program - Pizza Data/IO


    Introduction - Connecting and Manipulating Databases
    This week you’re going to replace the File IO operations your completed last week and replace them with database operations. During this exercise you will see the advantage of making the effort in creating a 3-tiered architecture that encapsulations the operations into the appropriate layer.
    Use your OmnyBus MySQL Account
    Updating the Pizza Order Program:
    Here is what you will need to do to get the Pizza Program to work.
    In the OmnyBus EDUPE server management application:
    Open the database you created.
    Create a table called "PizzaOrder" with the following fields
    1) id as an Int, set to primary key, set Autoincrement = yes
    2) firstName as a varchar of length 50
    3) lastName as a varchar of length 50
    4) size of type small int
    5) cheese as a tinyint (MySQL boolean)
    6) sausage as tinyint
    7) ham as a tinyint
    8) total as a double
    In the Netbeans (or Eclipse) project ensure that the MYSQL jar file is correctly referenced (in your assignments, you will have to move this file into your project and set the path to the jar file):
    Right click on the project name, then select "Properities".
    Select libaries
    Confirm that the mysql-connector.jar file is listed in the "Compile Time Libaries:"
    See the following that demonstrates how to set the driver, jar reference path:


    In the Data project, DataIO class update the following constant fields to showy our credential information:
    CONNECTION_STRING
    USER_NAME
    PASSWORD
    In the DataIO class there are TODO items (select WINDOW|ACTION ITEM to see list of todo, click to take you to the code location). You are then asked to modify the following methods to interact with the database.
    add method
    delete method
    update method
    getList method

    Learn More
  5. PRG420 Week 1 Individual Assignment Coding a Simple Hello world Java Program

    PRG420 Week 1 Individual Assignment Coding a Simple "Hello, world!" Java Program

    Regular Price: $7.00

    Special Price: $5.00

    PRG420 Week 1 Individual Assignment Coding a Simple "Hello, world!" Java Program


    Individual: Coding a Simple "Hello, world!" Java™ Program


    Includes Working Java Build and Program File and Explanation of Code
    Resource: Week One Coding Assignment Zip File (starter code for this assignment that includes placeholders)
    For this assignment, you will apply what you learned in analyzing a simple Java™ program by writing your own Java™ program. The Java™ program you write should do the following:
    • Display a prompt on the console asking the user to type in his or her first name
    • Construct the greeting string "Hello, nameEntered!"
    • Display the constructed greeting on the console
    Complete this assignment by doing the following:
    1. Download and unzip the linked zip file.
    2. Add comments to the code by typing your name and the date in the multi-line comment header.
    3. Replace the following lines with Java™ code as directed in the file:
    • LINE 1
    • LINE 2
    • LINE 3
    • LINE 4
    4. Comment each line of code you add to explain what you intend the code to do.
    5. Test and modify your Java™ program until it runs without errors and produces the results as described above.
    Note: Refer to this week's analyzing code assignment if you need help.
    Submit your Java source (.java) code file using the Assignment Files tab.


    /**********************************************************************
    * Program: PRG420Week1_CodingAssignment
    *  Purpose: Week 1 Individual Assignment #2
    * Programmer: YOUR FULL NAME GOES HERE
    * Class: PRG/420 PRG420 PRG 420
    * Creation Date: TODAY'S DATE GOES HERE
    *********************************************************************
    *
    **********************************************************************
    * Program Summary: This program asks the user for a one-word name
    *            and then displays a constructed greeting
    *            that looks like this:
    *
    *            Hello, NAME!
    **********************************************************************/
    package prg420week1_codingassignment;


    /**
     *
     * @author NETBEANS PLACES YOUR INITIALS HERE
     */


    import java.util.Scanner;


    public class PRG420Week1_CodingAssignment {


      public static void main(String[] args) {


        // Create a usable instance of an input device 
        LINE 1. INSTANTIATE AN INSTANCE OF SCANNER AND ASSIGN IT TO A VARIABLE OF TYPE SCANNER.


        // Prompt user for input
        LINE 2. USE THE PRINT() METHOD TO PROMPT THE USER FOR HIS OR HER FIRST NAME.


        // Capture first word and assign it to A VARIABLE
        LINE 3. USE THE NEXT() METHOD OF YOUR SCANNER INSTANCE TO ASSIGN A VALUE TO A STRING VARIABLE.


        // Construct the greeting
        LINE 4. USE THE PRINTLN() METHOD TO CONSTRUCT A CORRECTLY PUNCTUATED GREETING.


    }
    }

    Learn More
  6. PRG420 Week 2 Individual Assignment Coding a Program Containing if-then and switch Java Source

    PRG420 Week 2 Individual Assignment Coding a Program Containing if-then and switch

    Regular Price: $10.00

    Special Price: $7.00

    PRG420 Week 2 Individual Assignment Coding a Program Containing if-then and switch


    Individual: Coding a Program Containing if-then and switch


    Includes Working Java Build and Program File and Explanation of Code
    Resources:  Week Two Coding Assignment Zip File (starter code for this assignment that includes placeholders), and Week Two Recommended Activity Zip File (examples of how to code a switch statement, an if-then-else statement, and how to construct a string to display text onscreen).
    For this assignment, you will apply what you learned in analyzing Java™ code so far in this course by writing your own Java™ program.
    The Java™ program you write should do the following:
    • Accept user input that represents the number of sides in a polygon. Note: The code to do this is already written for you.
    • If input value is not between 3 and 5, display an informative error message
    • If input value is between 3 and 5, use a switch statement to display a message that identifies the correct polygon based on the number of sides matching the input number (e.g., triangle, rectangle, or polygon)
    Complete this assignment by doing the following:
    1. Download and unzip the linked Week Two Coding Assignment Zip File.
    2. Read the file carefully, especially the explanatory comments of what the existing code does.
    3. Add your name and the date in the multi-line comment header.
    4. Refer to the following linked Week Two Recommended Activity Zip File to see examples of how to code all of the Java™ statements (i.e., switch, println(), and if-then-else) you will need to write to complete this assignment.
    5. Replace the following lines with Java code as directed in the file:
    • LINE 1
    • LINE 2
    6. Comment each line of code you add to explain what you intend the code to do.
    7. Test and modify your Java™ program until it runs without errors and produces the results as described above.
    Note: Refer to this week's analyzing code assignment if you need help.
    Submit your Java source (.java) code file using the Assignment Files tab.


    /**********************************************************************
    * Program: PRG/420 Week 2
    * Purpose: Week 2 Coding Assignment
    * Programmer: Iam A. Student
    * Class: PRG/420 PRG420 PRG 420
    * Creation Date: 10/18/17
    *********************************************************************
    *
    **********************************************************************
    * Program Summary: This program demonstrates these basic Java concepts:
    * - defining variables of different types
    * - if-then and if-then-else logic
    * - constructing a string to display onscreen
    * - switch logic
    *
    * To finish assignment, you will add code where indicated. The
    * behavior of your completed assignment should be to accept an input
    * value for the number of sides of a two-dimensional figure. Based on that value,
    * your code should display the type of figure that corresponds to the number of polygon angles
    * indicated (3=triangle, 4=rectangle, etc.)
    *
    * Here are the specific requirements:
    *
    * After the user types in a value from 3 to 5 inclusive (i.e., 3, 4, or 5):
    *
    * 1. Your code determines whether the input value is out of range (less than 3 or more than 5)
    * and, if so, displays a meaningful error message on the screen and ends the program.
    *
    * 2. Because you will be comparing a single expression (the input value) to multiple constants (3, 4, and 5),
    * your code should use a switch statement to display the following message onscreen:
    *
    * If user inputs 3, onscreen message should say "A triangle has 3 sides."
    * If user inputs 4, onscreen message should say "A rectangle has 4 sides."
    * If user inputs 5, onscreen message should see "A pentagon has 5 sides."
    *
    * 3. Be sure to test your program. This means running your program multiple
    * times with test values 3, 4, 5, as well as at least two values that fall outside that range
    * (one lower than the lowest and one higher than the highest) and making sure
    * that the correct message displays for each value you input. Also be sure
    * that running your program does not cause any compiler errors.
    ***********************************************************************/


    package week2codingassignment;


    import java.util.Scanner;


    public class PRG420Week2_CodingAssignment {
    public static void main(String[] args) {
    String userInputStringOfAngles; // Declare a variable of type String to capture user input
    int numberOfAngles; // Declare a variable of type int to hold the converted user input
    Scanner myInputScannerInstance = new Scanner(System.in); // Recognize the keyboard
    System.out.print("Please type the integer 3, 4, or 5 and then press Enter: "); // Prompt the user
    userInputStringOfAngles= myInputScannerInstance.next(); // Capture user input as string
    numberOfAngles = Integer.parseInt(userInputStringOfAngles); // Convert the string to a number in case this will be useful later
    // LINE 1. CODE TO DETERMINE WHETHER USER INPUT IS OUT OF BOUNDS GOES HERE
    // LINE 2. SWITCH CODE TO PRINT CORRECT "SHAPE" MESSAGE BASED ON USER INPUT GOES HERE
    }
    }

    Learn More
  7. PRG420 Week 3 Individual Assignment Coding a Program Containing Loops Output and Code

    PRG420 Week 3 Individual Assignment Coding a Program Containing Loops

    Regular Price: $10.00

    Special Price: $7.00

    PRG420 Week 3 Individual Assignment Coding a Program Containing Loops


    Individual: Coding a Program Containing Loops


    Includes Working Java Build and Program File and Explanation of Code
    Resource:  Week Three Coding Assignment Zip File (starter code for this assignment that includes placeholders)
    For this assignment, you will apply what you learned in analyzing for, while, and do-while loops by writing these statements yourself. The Java™ program you write should do the following:
    • Display a pyramid of asterisks onscreen (i.e., a nested for loop)
    • Display the integers 10 to 1 in decreasing order, one number per line (i.e., a while/do-whlie loop)
    • Add 7 until the sum becomes greater than 157, at which point the program should display both the sum and the number of 7s added Complete this assignment by doing the following:
    1. Download and unzip the linked Week Three Coding Assignment Zip File.
    2. Add comments to the code by typing your name and the date in the multi-line comment header.
    3. Replace the following lines with Java™ code as directed in the file:
    • LINE 1
    • LINE 2
    • LINE 3
    4. Comment each line of code you add to explain what you intend the code to do and why you chose each type of loop.
    5. Test and modify your Java™ program until it runs without errors and produces the results as described above.
    Note: Refer to this week's analyzing code assignment if you need help.
    Submit your Java source (.java) code file using the Assignment Files tab.



    /**********************************************************************
    * Program: PRG420Week3_CodingAssignment
    *  Purpose: Week 3 Individual Assignment #2
    * Programmer: Iam A. Student
    * Class: PRG/420 PRG420 PRG 420
    * Creation Date: TODAY'S DATE GOES HERE
    ***********************************************************************
    *
    ***********************************************************************
    * Program summary: For, while, do-while loops; nested loops
    *
    * For this assignment, you will add code to create:
    *
    * a for loop nested inside another for loop
    * a while loop
    * a do-while loop
    *************************************************************************/


    package prg420week3_codingassignment;


    public class PRG420Week3_CodingAssignment {


    public static void main(String[] args) {


    // The following code should print asterisks: 1 on line 1, 2 asterists on line 2,
    // 3 on line 3, 4 on line 4... for as many lines as the variable linesOfAsterisks.
    // To do this, we can use 2 nested for loops. The first for loop is coded for you.
    // You will need to add another for lop, NESTED INSIDE the first, that prints
    // a certain # of asterisks based on the # of times the loop code has been executed.
    // The result should look like this:
    // *
    // **
    // ***
    // ****
    // *****
    // etc.
    int linesOfAsterisks = 5;
    for (int i = 1; i <= linesOfAsterisks; i++) { // for each line...
    // LINE 1. ADD A NESTED FOR LOOP THAT DISPLAYS ONE ASTERISK ON LINE 1, TWO ASTERISKS ON LINE 2, 3 ASTERISKS ON LINE 3, ETC.
    System.out.println();
    }
    //////////////////////////////////////////////////////////////////////
    // Add a while or do-while loop that displays the numbers from 10 to 1 in that order, like so:
    // 10
    // 9
    // 8
    // 7
    // ...
    // 1
    //////////////////////////////////////////////////////////////////////
    int num=10;
    //LINE 2. ADD A LOOP THAT DISPLAYS NUMBERS 10 TO 1 IN DECREASING ORDER (HINT: DECREMENT OPERATOR)
    ///////////////////////////////////////////////////////////////////////
    // Write a loop that adds 7s one at a time until the sum becomes > 157.
    // Then print out both the sum and the number of 7s that were aded.
    // Write a while or do-while loop, whichever you think is most appropriate.
    //////////////////////////////////////////////////////////////////////////
    int sum = 0;
    int numberOfSevens = 0;
    //LINE 3. ADD ANOTHER LOOP THAT ADDS 7s UNTIL SUM > 157. THEN DISPLAY SUM AND NUMBER OF SEVENS ADDED.
    }

    Learn More
  8. PRG420 Week 4 Individual Assignment Coding a Program Containing an Array Coding and Output

    PRG420 Week 4 Individual Assignment Coding a Program Containing an Array

    Regular Price: $10.00

    Special Price: $7.00

    PRG420 Week 4 Individual Assignment Coding a Program Containing an Array


    Individual: Coding a Program Containing an Array


    Includes Working Java Build and Program File and Explanation of Code
    Resource:  Week Four Coding Assignment Zip File (starter code for this assignment that includes placeholders)
    For this assignment, you will apply what you learned in analyzing a simple Java™ program by writing your own Java™ program that creates and accesses an array of integers. The Java™ program you write should do the following:
    • Create an array to hold 10 integers
    • Ask the user for an integer. Note: This code has already been written for you.
    • Populate the array. Note: The first element should be the integer input by the user. The second through tenth elements should each be the previous element + 100. For example, if the user inputs 10, the first array value should be 10, the second 110, the third 210, and so on.
    • Display the contents of the array on the screen in ascending index order.
    Complete this assignment by doing the following:
    1. Download and unzip the linked Week Four Coding Assignment Zip File.
    2. Read each line of the file carefully, including the detailed instructions at the top.
    3. Add comments to the code by typing your name and the date in the multi-line comment header.
    4. Replace the following lines with Java™ code as directed in the file:
    • LINE 1
    • LINE 2
    • LINE 3
    • LINE 4
    • LINE 5
    5. Comment each line of code you add to explain what you intend the code to do.
    6. Test and modify your Java™ program until it runs without errors and produces the results as described above.
    Note: Refer to this week's analyzing code assignment if you need help.
    Submit your Java source (.java) code file using the Assignment Files tab.


    /********************************************************************
    * Program:    PRG420Week4_CodingAssignment
    * Purpose:       Week 4 Individual Assignment #2
    * Programmer:    Iam A. Student
    * Class:         PRG/420  PRG420 PRG 420
    * Creation Date:   TODAY'S DATE GOES HERE
    *********************************************************************
    *
    *********************************************************************
    *  Program Summary: This program demonstrates these basic Java concepts:
    *     - Creating an array based on user input
    *     - Accessing and displaying elements of the array
    *
    * The program should declare an array to hold 10 integers.
    * The program should then ask the user for an integer.
    * The program should populate the array by assigning the user-input integer
    * to the first element of the array, the value of the first element + 100 to
    * the second element of the array, the value of the second element + 100 to
    * the third element of the array, the value of third element + 100 to
    * the fourth element of the array, and so on until all 10 elements of the
    * array are populated.
    *
    * Then the program should display the values of each of the array
    * elements onscreen. For example, if the user inputs 4, the output
    * should look like this:
    *
    * Enter an integer and hit Return: 4
    * Element at index 0: 4
    * Element at index 1: 104
    * Element at index 2: 204
    * Element at index 3: 304
    * Element at index 4: 404
    * Element at index 5: 504
    * Element at index 6: 604
    * Element at index 7: 704
    * Element at index 8: 804
    * Element at index 9: 904
    ***********************************************************************/
    package prg420week4_codingassignment;
    import java.util.Scanner;
    public class PRG420Week4_CodingAssignment {
     public static void main(String[] args) {
      
      // LINE 1. DECLARE AN ARRAY OF INTEGERS


      // LINE 2. ALLOCATE MEMORY FOR 10 INTEGERS WITHIN THE ARRAY.


      // Create a usable instance of an input device
      Scanner myInputScannerInstance = new Scanner(System.in);
      
      // We will ask a user to type in an integer. Note that in this practice
      // code  WE ARE NOT VERIFYING WHETHER THE USER ACTUALLY
      // TYPES AN INTEGER OR NOT. In a production program, we would
      // need to verify this; for example, by including
      // exception handling code. (As-is, a user can type in XYZ
      // and that will cause an exception.)
      System.out.print("Enter an integer and hit Return: ");
      
      // Convert the user input (which comes in as a string even
      // though we ask the user for an integer) to an integer
      int myFirstArrayElement = Integer.parseInt(myInputScannerInstance.next());
      
      // LINE 3. INITIALIZE THE FIRST ARRAY ELEMENT WITH THE CONVERTED INTEGER myFirstArrayElement
      


      // LINE 4. INITIALIZE THE SECOND THROUGH THE TENTH ELEMENTS BY ADDING 100 TO THE EACH PRECEDING VALUE.
      // EXAMPLE: THE VALUE OF THE SECOND ELEMENT IS THE VALUE OF THE FIRST PLUS 100;
      // THE VALUE OF THE THIRD ELEMENT IS THE VALUE OF THE SECOND PLUS 100; AND SO ON.


      
      // LINE 5. DISPLAY THE VALUES OF EACH ELEMENT OF THE ARRAY IN ASCENDING ORDER BASED ON THE MODEL IN THE TOP-OF-CODE COMMENTS.
      
     } 
    }

    Learn More
  9. PRG420 Week 5 Individual Assignment Coding a Program Containing Exception Handling Output and coding

    PRG420 Week 5 Individual Assignment Coding a Program Containing Exception Handling

    Regular Price: $10.00

    Special Price: $7.00

    PRG420 Week 5 Individual Assignment Coding a Program Containing Exception Handling


    Individual: Coding a Program Containing Exception Handling


    Includes Working Java Build and Program File and Explanation of Code
    Resource:  Week Five Coding Assignment Zip File (starter code for this assignment that includes placeholders)
    For this assignment, you will apply what you learned in analyzing a simple Java™ program by writing your own Java™ program. The Java™ program you write should do the following:
    • Organize the code capable of throwing an exception of type ParseException as a try block.
    • Include a catch block to handle a ParseException error thrown by the try block.
    • Include a hard-coded error that results in a ParseException to prove that the code can catch and handle this type of exception.
    Complete this assignment by doing the following:
    1. Download and unzip the linked Week Five Coding Assignment Zip File.
    2. Add comments to the code by typing your name and the date in the multi-line comment header.
    3. Replace the following lines with Java™ code as directed in the file:
    • LINE 1
    • LINE 2
    4. Replace the value assigned with one of the variables so that the program throws an exception.
    5. Comment each line of code you add to explain what you intend the code to do. Be sure to include a comment for the replacement value you added in Step 4 that causes the program to throw an exception.
    6. Test and modify your Java™ program until it runs without errors and produces the results described above.
    Note: Refer to this week's analyzing code assignment if you need help.
    Submit your Java application file using the Assignment Files tab.


    /********************************************************************
    * Program:    PRG420Week5_CodingAssignment
    * Purpose:       Week 5 Individual Assignment #2
    * Programmer:    Iam A. Student
    * Class:         PRG/420  PRG420 PRG 420
    * Creation Date:   TODAY'S DATE GOES HERE
    *********************************************************************
    *
    *********************************************************************
    * Program Summary:
    * This program converts a given date to a string.  
    * The code includes exception handling for a ParseException.
    ************************************************************************************/
    package prg420week5_codingassignment;
    import java.util.*;
    import java.text.*;
    public class PRG420Week5_CodingAssignment {
     public static void main(String[] args){
      // The getInstance() method returns a Calendar object whose calendar fields have been initialized with the current date and time.
      Calendar calendar = Calendar.getInstance(); {
      LINE 1. BEGIN THE TRY BLOCK.
      String str_date="01-Nov-17"; // Declare a string that we will use later to format a date like this: ##-XXX-##
      DateFormat formatter; // Declare an object of type DateFormat so that we can call its parse() method later
      Date myFormattedDate; // Declare a variable of type Date to hold the formatted date
      formatter = new SimpleDateFormat("dd-MMM-yy"); // Assign a specific date format to the formatter variable
      // The given date is taken as a string that is converted into a date type by using
      // the parse() method
      myFormattedDate = (Date)formatter.parse(str_date); // setting up the format
      System.out.println("The formatted date is " + myFormattedDate);
      System.out.println("Today is " +calendar.getTime() );
      LINE 2. WRITE THE CATCH BLOCK TO CATCH EXCEPTIONS OF TYPE ParseException (TO HANDLE EXCEPTION, SIMPLY PRINT THE EXCEPTION)
      }
     }
    }

    Learn More
  10. PRG 421 Week 1 Individual Analyze Assignment Analyzing a Java Program Containing Abstract and Derived Classes

    PRG 421 Week 1 Individual Analyze Assignment Analyzing a Java Program Containing Abstract and Derived Classes

    Regular Price: $6.00

    Special Price: $4.00

    PRG 421 Week 1 Individual Analyze Assignment Analyzing a Java Program Containing Abstract and Derived Classes


    "Analyzing a Java™ Program Containing Abstract and Derived Classes"
    The purpose of creating an abstract class is to model an abstract situation.
    Example:
    You work for a company that has different types of customers: domestic, international, business partners, individuals, and so on. It well may be useful for you to "abstract out" all the information that is common to all of your customers, such as name, customer number, order history, etc., but also keep track of the information that is specific to different classes of customer. For example, you may want to keep track of additional information for international customers so that you can handle exchange rates and customs-related activities, or you may want to keep track of additional tax-, company-, and department-related information for business customers.
    Modeling all these customers as one abstract class ("Customer") from which many specialized customer classes derive or inherit ("International Customer," "Business Customer," etc.) will allow you to define all of that information your customers have in common and put it in the "Customer" class, and when you derive your specialized customer classes from the abstract Customer class you will be able to reuse all of those abstract data/methods.This approach reduces the coding you have to do which, in turn, reduces the probability of errors you will make. It also allows you, as a programmer, to reduce the cost of producing and maintaining the program.
    In this assignment, you will analyze Java™ code that declares one abstract class and derives three concrete classes from that one abstract class. You will read through the code and predict the output of the program.
    Read through the linked Java™ code carefully.
    Predict the result of running the Java™ code. Write your prediction into a Microsoft® Word document, focusing specifically on what text you think will appear on the console after running the Java™ code.
    In the same Word document, answer the following question:
    Why would a programmer choose to define a method in an abstract class, such as the Animal constructor method or the getName() method in the linked code example, as opposed to defining a method as abstract, such as the makeSound() method in the linked example?


    Supporting Material: Week One Analyze Assignment Text File
    /**********************************************************************
    * Program: PRG/421 Week 1 Analyze Assignment
    * Purpose: Analyze the coding for an abstract class
    * and two derived classes, including overriding methods
    * Programmer: Iam A. Student
    * Class: PRG/421r13, Java Programming II
    * Instructor:
    * Creation Date: December 13, 2017
    *
    * Comments:
    * Notice that in the abstract Animal class shown here, one method is
    * concrete (the one that returns an animal's name) because all animals can
    * be presumed to have a name. But one method, makeSound(), is declared as
    * abstract, because each concrete animal must define/override the makeSound() method
    * for itself--there is no generic sound that all animals make.
    **********************************************************************/


    package mytest;


    // Animal is an abstract class because "animal" is conceptual
    // for our purposes. We can't declare an instance of the Animal class,
    // but we will be able to declare an instance of any concrete class
    // that derives from the Animal class.
    abstract class Animal {
    // All animals have a name, so store that info here in the superclass.
    // And make it private so that other programmers have to use the
    // getter method to access the name of an animal.


    private final String animalName;
    // One-argument constructor requires a name.
    public Animal(String aName) {
    animalName = aName;
    }


    // Return the name of the animal when requested to do so via this
    // getter method, getName().
    public String getName() {
    return animalName;
    }


    // Declare the makeSound() method abstract, as we have no way of knowing
    // what sound a generic animal would make (in other words, this
    // method MUST be defined differently for each type of animal,
    // so we will not define it here--we will just declare a placeholder
    // method in the animal superclass so that every class that derives from
    // this superclass will need to provide an override method
    // for makeSound()).
    public abstract String makeSound();
    };


    // Create a concrete subclass named "Dog" that inherits from Animal.
    // Because Dog is a concrete class, we can instantiate it.
    class Dog extends Animal {
    // This constructor passes the name of the dog to
    // the Animal superclass to deal with.
    public Dog(String nameOfDog) {
    super(nameOfDog);
    }


    // This method is Dog-specific.
    @Override
    public String makeSound() {
    return ("Woof");
    }
    }


    // Create a concrete subclass named "Cat" that inherits from Animal.
    // Because Cat is a concrete class, we can instantiate it.
    class Cat extends Animal {
    // This constructor passes the name of the cat on to the Animal
    // superclass to deal with.
    public Cat(String nameOfCat) {
    super(nameOfCat);
    }


    // This method is Cat-specific.
    @Override
    public String makeSound() {
    return ("Meow");
    }
    }


    class Bird extends Animal {
    // This constructor passes the name of the bird on to the Animal
    // superclass to deal with.
    public Bird (String nameOfBird) {
    super(nameOfBird);
    }


    // This method is Bird-specific.
    @Override
    public String makeSound() {
    return ("Squawk");
    }
    }


    public class MyTest {
    public static void main(String[] args) {
    // Create an instance of the Dog class, passing it the name "Spot."
    // The variable aDog that we create is of type Animal.
    Animal aDog = new Dog("Spot");
    // Create an instance of the Cat class, passing it the name "Fluffy."
    // The variable aCat that we create is of type Animal.
    Animal aCat = new Cat("Fluffy");
    // Create an instance of (instantiate) the Bird class.
    Animal aBird = new Bird("Tweety");
    //Exercise two different methods of the aDog instance:
    // 1) getName() (which was defined in the abstract Animal class)
    // 2) makeSound() (which was defined in the concrete Dog class)
    System.out.println("The dog named " + aDog.getName() + " will make this sound: " + aDog.makeSound());
    //Exercise two different methods of the aCat instance:
    // 1) getName() (which was defined in the abstract Animal class)
    // 2) makeSound() (which was defined in the concrete Cat class)
    System.out.println("The cat named " + aCat.getName() + " will make this sound: " + aCat.makeSound());
    System.out.println("The bird named " + aBird.getName() + " will make this sound: " + aBird.makeSound());
    }
    }

    Learn More

Items 31 to 40 of 110 total

per page
Page:
  1. 2
  2. 3
  3. 4
  4. 5
  5. 6

Grid  List 

Set Ascending Direction