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 1 to 10 of 20 total

per page
Page:
  1. 1
  2. 2

Grid  List 

Set Ascending Direction
  1. Big Java Chapter 8 Programming Exercise P8.3

    Big Java Chapter 8 Programming Exercise P8.3

    Regular Price: $5.00

    Special Price: $4.00

    Big Java Chapter 8 Programming Exercise P8.3


    Real cash registers can handle both bills and coins. Design a single class that expresses the commonality of these concepts. Redesign the CashRegister class and provide a method for entering payments that are described by your class. Your primary challenge is to come up with a good name for the class.

    Learn More
  2. PRG 421 Week 3 Individual Analyze Assignment Java Code That Sorts Extracts Data and Saves It To a Collection

    PRG 421 Week 3 Individual Analyze Assignment Java Code That Sorts Extracts Data and Saves It To a Collection

    Regular Price: $6.00

    Special Price: $4.00

    PRG 421 Week 3 Individual Analyze Assignment Java Code That Sorts Extracts Data and Saves It To a Collection


    "Java Code That Sorts, Extracts Data and Saves It To a Collection" text file
    For this assignment, you will analyze code that uses a file input stream and a file output stream.
    Read through the linked Java™ code.
    In a Microsoft® Word document, answer the following questions:
    Could this program be run as is? If not, what is it lacking?
    Does this program modify the contents of an input stream? In what way?
    What are the results of running this code?
    Submit your completed Word document to the Assignment Files tab.
    Here is the code to answer the questions with:


    // import the needed classes
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Collections;



    public class Datasort {


    public static void main (String [] args) throws IOException {


    File fin = new File("e:\\input.txt");   // input file on e: drive (with data)  
    File fout = new File("e:\\sorted.txt");   // create an out file on e: drive


    // Java FileInputStream class obtains input bytes from a file
    FileInputStream fis = new FileInputStream(fin); 
    FileOutputStream fos = new FileOutputStream(fout);


    // buffering characters so as to provide for the efficient reading of characters, arrays, and lines
    BufferedReader in = new BufferedReader(new InputStreamReader(fis));
    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fos));


    // declare an array in-line, ready for the sort


    String aLine;
    ArrayList<String> al = new ArrayList<String> ();


    int i = 0;
    while ((aLine = in.readLine()) != null) {
    // set the sort for values is greater than 0
       if (!aLine.trim().startsWith("-") && aLine.trim().length() > 0) {
           al.add(aLine);
           i++;
               }
           }


    Collections.sort(al);   // sorted content to the output file
    for (String s : al) {
    System.out.println(s);
       out.write(s);
       out.newLine();
       out.newLine();
       }
    // close the 2 files
           in.close();
           out.close();
       }
    }

    Learn More
  3. Stack to print the Prime Factors Java Program

    Stack to print the Prime Factors Java Program

    $5.00

    Stack to print the Prime Factors Java Program


    For a given integer n > 1, the smallest integer d > 1 that divides n is a prime factor. We can find the prime factorization of n if we find d and then replace n by the quotient of n divided by d, repeating this until n becomes 1.


    Write a Java program that uses a stack (in Arrays) to print the prime factors of a positive integer in descending order.


    For example, for n = 3960, the program should produce:
    11*5*3*3*2*2*2

    Learn More
  4. 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
  5. 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
  6. Remove hyphens from a word java program

    Remove hyphens from a word Java program

    $5.00

    Remove hyphens from a word Java program


    This program will remove the hyphens from a word. a string (delimited by whitespaces) with hyphens is divided into substrings delimited by hyphen.
    Program outputs shall go to the console display.
    input: WORD-word
    expected output: WORD word

    Learn More
  7. 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
  8. PRG421 Week 1 Individual Coding Assignment Object-Oriented Programming Concepts

    PRG421 Week 1 Individual Coding Assignment Object-Oriented Programming Concepts

    Regular Price: $10.00

    Special Price: $7.00

    PRG421 Week 1 Individual Coding Assignment Object-Oriented Programming Concepts


    For this assignment, you will modify existing code to create a single Java™ program named BicycleDemo.java that incorporates the following:


    An abstract Bicycle class that contains private data relevant to all types of bicycles (cadence, speed, and gear) in addition to one new static variable: bicycleCount. The private data must be made visible via public getter and setter methods; the static variable must be set/manipulated in the Bicycle constructor and made visible via a public getter method.
    Two concrete classes named MountainBike and RoadBike, both of which derive from the abstract Bicycle class and both of which add their own class-specific data and getter/setter methods.


    Read through the "Lesson: Object-Oriented Programming Concepts" on The Java™ Tutorials website.
    Download the linked Bicycle class, or cut-and-paste it at the top of a new Java™ project named BicycleDemo.
    Download the linked BicycleDemo class, or cut-and-paste it beneath the Bicycle class in the BicycleDemo.java file.
    Optionally, review this week's Individual "Week One Analyze Assignment," to refresh your understanding of how to code derived classes.


    Adapt the Bicycle class by cutting and pasting the class into the NetBeans editor and completing the following:
    Change the Bicycle class to be an abstract class.
    Add a private variable of type integer named bicycleCount, and initialize this variable to 0.
    Change the Bicycle constructor to add 1 to the bicycleCount each time a new object of type Bicycle is created.
    Add a public getter method to return the current value of bicycleCount.
    Derive two classes from Bicycle: MountainBike and RoadBike. To the MountainBike class, add the private variables tireTread (String) and mountainRating (int). To the RoadBike class, add the private variable maximumMPH (int).
    Using the NetBeans editor, adapt the BicycleDemo class as follows:
    Create two instances each of MountainBike and RoadBike.
    Display the value of bicycleCount on the console.
    Comment each line of code you add to explain what you added and why. Be sure to include a header comment that includes the name of the program, your name, PRG/421, and the date.
    Rename your JAVA file to have a .txt file extension.
    Submit your TXT file to the Assignment Files tab.


    package bicycledemo;


    class Bicycle {
    int cadence = 0;
    int speed = 0;
    int gear = 1;


    void changeCadence(int newValue) {
    cadence = newValue;
    }


    void changeGear(int newValue) {
    gear = newValue;
    }


    void speedUp(int increment) {
    speed = speed + increment;  
    }


    void applyBrakes(int decrement) {
    speed = speed - decrement;
    }


    void printStates() {
    System.out.println("cadence:" +
    cadence + " speed:" +
    speed + " gear:" + gear);
    }
    }
    class BicycleDemo {
    public static void main(String[] args) {


    // Create two different
    // Bicycle objects
    Bicycle bike1 = new Bicycle();
    Bicycle bike2 = new Bicycle();


    // Invoke methods on
    // those objects
    bike1.changeCadence(50);
    bike1.speedUp(10);
    bike1.changeGear(2);
    bike1.printStates();


    bike2.changeCadence(50);
    bike2.speedUp(10);
    bike2.changeGear(2);
    bike2.changeCadence(40);
    bike2.speedUp(10);
    bike2.changeGear(3);
    bike2.printStates();
    }
    }

    Learn More
  9. Big Java Chapter 8 Programming Exercise P8.4 BankAccount

    Big Java Chapter 8 Programming Exercise P8.4 BankAccount Solution

    Regular Price: $5.00

    Special Price: $4.00

    Big Java Chapter 8 Programming Exercise P8.4 BankAccount


    Enhance the BankAccount class by adding preconditions for the constructor and the deposit method that require the amount parameter to be at least zero, and a precondition for the withdraw method that requires amount to be a value between 0 and the current balance. Use assertions to test the preconditions.

    Learn More
  10. PRG 421 Week 1 Hello World Program

    PRG 421 Week 1 Hello World Program

    Regular Price: $8.00

    Special Price: $5.00

    PRG 421 Week 1 Hello World Program

    Design, implement, test, and debug a GUI-based version of a “Hello, World!” program.
    Create a JFrame that includes a JLabel that reads “Hello, World!” Use a layout manager of your choice.
    Include an Exit button to close the program.
    Submit the .java source file.

    Learn More

Items 1 to 10 of 20 total

per page
Page:
  1. 1
  2. 2

Grid  List 

Set Ascending Direction