Welcome to AssignmentCache!

Search results for 'cit-150 chapter5 individual case'

Items 21 to 30 of 222 total

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

Grid  List 

Set Ascending Direction
  1. DAT380 Week 2 Individual Assignment Object-Oriented Data Model

    DAT/380 Week 2 Individual Assignment Object-Oriented Data Model and SQL Query Definition for DreamHome Case

    Regular Price: $15.00

    Special Price $12.00

    DAT/380 Week 2 Individual Assignment Object-Oriented Data Model and SQL Query Definition for DreamHome Case

    Consider any relevant feedback from your Week One Individual Assignment titled, "DreamHome Case Study" that will support the completion of this week's assignment.

    Create a data model for an object-oriented database in Microsoft Visio using the following resources:
    The information presented in Appendix A, "User Requirements Specification for DreamHome Case Study" of Database Systems: A Practical Approach to Design, Implementation and Management (6th edition)
    The distributed database created in the Week One Individual Assignment, "DreamHome Case Study"

    Write a minimum of four queries for building the database structure and map to the data model.
    Note: The results of this assignment will be used in future DreamHome-related Individual Assignments in Weeks Three, Four, and Five.

    Compress the following files into a ZIP folder:
    The Microsoft Visio file with the data model for an object-oriented database.
    Microsoft Word file containing the SQL queries for building the database structure.

    Learn More
  2. OOP2200 Lab 8 Structs and File IO main cpp

    OOP2200 Lab 8 Structs and File I/O CPP

    Regular Price: $15.00

    Special Price $12.00

    OOP2200 Lab 8 Structs and File I/O CPP
     
    This lab assignment will be completed by pairs of students. Submissions by individual students will not be accepted under normal circumstances. The intent is that the two students work together. In this lab you will be creating a “Plain-Old-Data” structure to store basic pay record information. You will use that structure to store raw pay record data read from a data file and produce a formatted report as a text file.

    Raw Data
    The data file "hours.txt" (provided), stores data for a number of employees. Each employee is recorded as follows: first name, last name, number of hours worked this week, and wage-per-hour. It currently contains the following data, but please note the file your instructor uses to test your program may contain a different number of records.
    John Smith 25.0 15.00
    Mary Jones 33.5 17.50
    Pat Brown 40.0 21.00
    Jen Simpson 37.5 18.00
    Gary Phillips 15.0 11.25

    PayRecord struct
    Create a data structure called PayRecord that has data-members for each of the four fields of information we are recording: first name, last name, number of hours worked this week, and wage-per-hour. When you read a line from the input file, you will be storing it in a PayRecord struct.

    Reading the Input File and Writing to the Output File
    Read raw data from the "hours.txt" data file (using your PayRecord struct) and produce a report in a file called "pay.txt". The report must contain the following:
    • Each employee name in the format first initial only, followed by ".", followed by last name. (e.g. Thom MacDonald becomes T. MacDonald)
    • The pay for each employee (hours worked * wage) formatted as currency.
    • The grand total paid to all employees for the week.
    Use the following may as a guide. You should try to match the format of this report as closely as possible.
    YOUR NAME
    PAY FOR THIS WEEK
    =========================
    J. Smith $ 375.00
    M. Jones $ 586.25
    P. Brown $ 840.00
    J. Simpson $ 675.00
    G. Phillips $ 168.75
    =========================
    Total: $ 2645.00

    Notes:
    1. Ensure that both the input and output files open properly. You should not process any file that is not open. Ensure to close both files when complete.
    2. Each employee occurs in the data file one time only. If any of the names appear in your report more than once, you have made a logic error.
    3. You are not required to output the report to the screen.
    4. One viable approach is to read one line from the input file and then write one line to the report in a loop until there are not more records. Another approach is to read all the records in the input file into a vector first, then produce the report from the vector. Either approach is fine. There is no explicit requirement to read and store all of the pay records before you begin writing the report.
    General Requirements
    • Include an opening comment with both partner's names, the name of the program, the date, and a short description.
    • Follow the course coding standards! Use descriptive names and sensible data-types for variables, constants, functions, etc. that follow our naming conventions.
    • Use good spacing and make sure braces ({}) are located where they are supposed to be, and indentation follows Allman style.
    • Attach your unzipped source code file(s) (.cpp, .h) to the assignment folder. Nothing else please.

    Learn More
  3. DAT380 Week 1 Individual Assignment distributed database for DreamHome Case

    DAT/380 Week 1 Individual Assignment distributed database for DreamHome Case

    Regular Price: $12.00

    Special Price $10.00

    DAT/380 Week 1 Individual Assignment distributed database for DreamHome Case

    Resource:
    Appendix A, "User Requirements Specification for DreamHome Case Study" of Database Systems: A Practical Approach to Design, Implementation and Management (6th edition).
    Review the "User Requirements Specification for DreamHome Case Study" of Database Systems: A Practical Approach to Design, Implementation and Management.

    Design a distributed database for DreamHome and illustrate it in Microsoft Visio.

    Include the following in your database:
    - Models representing the conceptual, logical, and physical database designs
    - Annotations identifying the appropriate elements. For example, the Physical Model annotations would include design base relations; identification of primary keys, foreign keys, and alternate keys; some data definitions (NOT NULL);  relational integrity constraints; and general constraints

    Note: The results of this assignment will be used in future DreamHome-related Individual Assignments in Weeks Two, Three, Four, and Five.

    Submit the Microsoft Visio files to the Assignment Files tab.

    Learn More
  4. New Perspectives HTML5 and CSS3 7th Edition Tutorial 10 Case 4 VoterWeb vw_result

    New Perspectives HTML5 and CSS3 7th Edition Tutorial 10 Case 4 VoterWeb

    Regular Price: $20.00

    Special Price $15.00

    New Perspectives HTML5 and CSS3 7th Edition Tutorial 10 Case 4 VoterWeb

    VoterWeb Pam Carls is a manager for the website Voter Web, which compiles voting totals and statistics from local and national elections. Pam has the results of recent congressional elections from eight districts in Minnesota stored as multidimensional arrays in a JavaScript file. Pam wants you to create a script displaying these results and calculating the vote percentage for each candidate within each race. A preview of the page is shown in Fig 10-38

    Complete the following:
    1. Use your editor to open the vw_election_txt.html and vw_results_txt.js files from the html10 case4 folder. Enter your name and the date in the comment section of each file, and save them as vw_election.html and vw_results.js respectively.

    2. Go to the vw_election.html file in your editor. Directly above the closing tag, insert script elements to link the page to the vw_congminn.js and vw_results.js files in that order. Defer the loading and running of both script files until after the page has loaded.

    3. Scroll down the file and, directly above the footer, insert an empty section element. You will write the HTML code of the election report in this element. Save your changes to the file.

    4. Open the vw_congminn.js file in your editor and study the contents. Note that the file contains the results of 8 congressional elections in Minnesota. The candidate information is stored in multidimensional arrays named candidate, party, and votes. Do not make any changes to this file.

    5. Go to the vw_results.js file in your editor. Declare a variable named reportHTML containing the following HTML text
    <h1>title</h1>
    where title is the value of the raceTitle variable stored in the vw_congminn.js file.

    6. Create a for loop that loops through the contents of the race array using i as the counter variable. Place the commands specified in Steps a through e within this program for loop:
    a. Create a variable named totalVotes that will store the total votes cast in each race. Set its initial value to 0.
    b. Calculate the total votes cast in the current race by applying the forEach() method to ith index of the votes array using the calcSum() function as the callback function.
    c. Add the following HTML text to the value of the reportHTML variable to write the name of the current race in the program loop
    <table>
    <caption>race</caption>
    <tr><th>Candidate</th><th>Votes</th></tr>
    where race is the ith index of the race array.
    d. Call the candidateRows() function (you will create this function shortly) using the counter variable i and the totalVotes variable as parameter values. Add the value returned by this function to the value of the reportHTML variable.
    e. Add the text </table> to the value of the reportHTML variable.

    7. After the for loop has completed, write the value of the reportHTML variable into the innerHTML of the first (and only) section element in the document.

    8. Next, create the candidateRows() function. The purpose of this function is to write individual table rows for each candidate, showing the candidate's name, party affiliation, vote total, and vote percentage. The candidateRows() function has two parameters named raceNum and totalVotes. Place the commands in Steps a through c within this function.
    a. Declare a local variable named rowHTML that will contain the HTML code for the table row. Set the initial value of this variable to an empty text string.
    b. Create a for loop in which the counter variable j goes from 0 to 2 in steps of 1 unit. Within the for loop do the following:
     i. Declare a variable named candidateName that retrieves the name of the current candidate and the current race. (Hint: Retrieve the candidate name from the multidimensional candidate array using the reference, candidate[raceNum][j].)
     ii. Declare a variable named candidateParty that retrieves the party affiliation of the current candidate in the current race from the multidimensional party array.
     iii. Declare a variable named candidateVotes that retrieves the votes cast for the current candidate in the current race from the multidimensional votes array.
     iv. Declare a variable named candidatePercent equal to the value returned by the calcPercent() function, calculating the percentage of votes received by the current candidate in the loop. Use candidateVotes as the first parameter value and totalVotes as the second parameter value.
     v. Add the following HTML code to the value of the rowHTML variable
     <tr>
     <td>name (party)</td>
     <td>votes (percent)</td>
     </tr>
     where name is the value of candidateName, party is the value of candidateParty, votes is the value of candidateVotes, and percent is the value of candidatePercent. Apply the toLocaleString() method to votes in order to display the vote total with a thousands separator. Apply the toFixed(1) method to percent in order to display percentage values to 1 decimal place.
    c. Return the value of the rowHTML variable.

    9. Save your changes to the file, and then load vw_election.html in your browser. Verify that the three candidate names, party affiliations, votes, and vote percentages are shown for each of the eight congressional races.

    10. Pam also wants the report to display the vote percentages as bar charts with the length of the bar corresponding to the percentage value. Return to the vw_results.js file in your editor. At the bottom of the file, create a function named createBar() with one parameter named partyType. Add the commands described in Steps a through b to the function:
    a. Declare a variable named barHTML and set its initial value to an empty text string.
    b. Create a switch/case statement that tests the value of the partyType parameter.
    If partyType equal "D" set barHTML equal to:
    <td class="dem"></td>
    If partyType equals "R" set barHTML equal to:
    <td class="rep"></td>
    Finally, if partyType equals "I" set barHTML to:
    <td class="ind"></td>

    11. Return the value of barHTML.
    Next, add these empty data cells to the race results table, with one cell for every percentage point cast for the candidate.

    12. Scroll up to the candidateRows() function. Directly before the line that adds the HTML code to the value of the rowHTML variable, insert a for loop with a counter variable k that goes from 0 up to a value less than candidatePercent in increments of 1 unit. Each time through the loop call the createBar() function using candidateParty and candidatePercent as the parameter values.

    13. Add comments throughout the file with descriptive information about the variables and functions.

    14. Save your changes to the file, and then reload vw_election.html in your browser. Verify that each election table shows a bar chart with different the length of bars representing each candidate’s vote percentage.

    Learn More
  5. New Perspectives HTML5 and CSS3 7th Edition Tutorial 10 Case 1 Trophy Case Sports tc_order

    New Perspectives HTML5 and CSS3 7th Edition Tutorial 10 Case 1 Trophy Case Sports

    Regular Price: $20.00

    Special Price $15.00

    New Perspectives HTML5 and CSS3 7th Edition Tutorial 10 Case 1 Trophy Case Sports

    Trophy Case Sports Sarah Nordheim manages the website for Trophy Case Sports, a sports memorabilia store located in Beavercreek, Ohio. She has asked you to work on creating a script for a shopping cart page. The script should take information on the items that the customer has purchased and present in it table form, calculating the total cost of the order. A preview of the page you will create is shown in Figure 10-35.

    Sarah has already designed the page layout. Your job will be to use JavaScript to enter the order information (this task will later be handled by a script running on website) and to write a script that generates the HTML code for the shopping cart table.

    Complete the following:
    1. Use your editor to open the tc_cart_txt.html, tc_cart_txt.js and tc_order_txt.js files from the htm10 case 1 folder. Enter your name and the date in the comment section of each file, and save them as tc_cart.html, tc_cart.js and tc_order.js respectively.

    2. Go to the tc_cart.html file in your editor. Directly above the closing </head> tag, insert script elements to link the page to the tc_order.js and tc_cart.js files in that order. Defer the loading and running of both script files until after the page has loaded.

    3. Scroll down the file and directly below the h1 heading titled "Shopping Cart" insert a div element with the ID cart.

    4. Save your changes to the file and go to the tc_ordet.js file in your editor.

    5. Within the tc_order.js file, you will create arrays containing information on a sample customer order. Create an array named item that will contain the ID numbers of the items purchased by the customer. Add the following four item numbers to the array: 10582, 23015, 41807, and 10041.

    6. Create an array named itemDescription containing the following item descriptions:
    • 1975 Green Bay Packers Football (signed), Item 10582
    • Tom Land, 1955 Football Card (unsigned), Item 23015
    • 1916 Army-Navy Game, Framed Photo (signed), Item 41807
    • Protective Card Sheets, Rem 10041

    7. Create an array named itemPrice containing the following item prices: 149.93, 89.98, 334.93, and 22.67.

    8. Create an array named itemQty containing the following quantities that the customer ordered of each item: 1, 1, 1, and 4.

    9. Save your changes to the file, and then open the tc_cart.js file in your editor.

    10. In your script, you will calculate a running total of the cost of the order. Declare a variable named orderTotal and set its initial value to 0.

    11. Declare a variable named cartHTML that will contain the HTML code for the contents of the shopping cart, which will be displayed as a table. Set its initial value to the text string:
    <table>
    <tr>
    <th>Item</th><th>Description</th><th>Price</th><th>Qty</th><th>Total</th>
    </tr>

    12. Create a for loop that loops through the entries in the item array. Each time through the loop, execute the commands described in Steps a through e.
    a. Add the following HTML code to the value of the cartHTML variable
    <tr> <td><img src='tc_item.png' alt='item' /> </td>
    where item is the current value from the item array.
    b. Add the following HTML code to the cartHTML variable to display the description, price, and quantity ordered of the item
    <td> description</td> <td>price</td> <td>quantity</td>
    where description is the current value from the itemDescription array, price is the current value from the itemPrice array preceded by a $ symbol, and quantity is from the itemQty array.
    c. Declare a variable named itemCost equal to the price value multiplied by the quantity value for the current item.
    d. Add the following HTML code to the cartHTML variable to display the cost for the item(s) ordered, completing the table row
    <td>$cost</td></tr>
    where cost is the value of the itemCost variable, preceded by a $ symbol.
    e. Add the value of the itemCost variable to the order Total variable to keep a running total of the total cost of the customer order.

    13. After the tor loop has completed, add the following HTML code to the value of the cartHTML variable, completing the shopping cart table
    <tr>
    <td colspan= '4'>Subtotal</td>
    <td>Total</td>
    </tr>
    </table>
    where total is the value of the orderTotal variable, preceded by a $ symbol.

    14. Apply the cartHTML value to the inner HTML of the div element with the ID cart.

    15. Document your script file with appropriate comments, and then save your work.

    16. Open the tc_cart.html file in your browser and verify that the page now shows the shopping cart data for the sample customer order.

    Learn More
  6. PRG 421 Week 4 Individual Analyze Assignment Analyzing a Multithreaded Program

    PRG 421 Week 4 Individual Analyze Assignment Analyzing a Multithreaded Program

    Regular Price: $7.00

    Special Price $5.00

    PRG 421 Week 4 Individual Analyze Assignment Analyzing a Multithreaded Program

    Deadlock occurs when no processing can occur because two processes that are waiting for each other to finish. For example, imagine that two processes need access to a file or database table row in order to complete, but both processes are attempting to access that resource at the same time. Neither process can complete without the other releasing access to the required resource, so the result is deadlock.
    Read and analyze code in the linked document that spawns two different threads at the same time.
    In a Microsoft® Word file, predict the results of executing the program, and identify whether a deadlock or starvation event will occur and, if so, at what point in the code.
    Submit your Word file to the Assignment Files tab.
    1. Predict the results of executing the program.
    2. Identify whether a deadlock or starvation event will occur and, if so, at what point in the code.

    /**********************************************************************
    * Program: Week 4 Analyze a Multithreaded Program
    * Purpose: Review the code and predict the results for the program execution.
    * Programmer: Iam A. student
    * Instructor: xxx
    ***********************************************************************/
    Package example deadlk;

    public class Deadlock {
    public static Object Lock1 = new Object(); // aacquires lock on the Lock1 object
    public static Object Lock2 = new Object(); // aacquires lock on the Lock2 object
    public static void main(String args[]) {
    ThreadDemo1 T1 = new ThreadDemo1(); // define the new threads
    ThreadDemo2 T2 = new ThreadDemo2(); // and set name for the threads
    T1.start();
    T2.start();
    }

    private static class ThreadDemo1 extends Thread {
    public void run() {
    synchronized (Lock1) {
    // synchronized Lock1 and Lock 2 will hold the thread until release
    System.out.println("Thread 1: Holding lock 1...");
    try { Thread.sleep(10); } // pause for 10 secs, then access thread
    catch (InterruptedException e) {} // if exception happens, “catch it”
    System.out.println("Thread 1: Waiting for lock 2..."); // display wait condition
    synchronized (Lock2) {
    System.out.println("Thread 1: Holding lock 1 & 2...");
    }
    }
    }
    }

    private static class ThreadDemo2 extends Thread {
    public void run() {
    synchronized (Lock2) {
    System.out.println("Thread 2: Holding lock 2...");
    try { Thread.sleep(10); } // pause for 10 secs, then access thread
    catch (InterruptedException e) {} // if exception happens, “catch it”
    System.out.println("Thread 2: Waiting for lock 1..."); // display wait condition
    synchronized (Lock1) {
    System.out.println("Thread 2: Holding lock 1 & 2...");
    }
    }
    }
    }
    }

    Learn More
  7. PRG421 Week 3 Individual Coding Assignment

    PRG 421 Week 3 Individual Coding Assignment

    Regular Price: $10.00

    Special Price $7.00

    PRG 421 Week 3 Individual Coding Assignment

    For this assignment, you will develop "starter" code. After you finish, your code should access an existing text file that you have created, create an input stream, read the contents of the text file, sort and store the contents of the text file into an ArrayList, then write the sorted contents via an output stream to a separate output text file.
    Copy and paste the following Java™ code into a JAVA source file in NetBeans:
     
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
     
    public class Datasort {
     
    public static void main (String [] args)  {
     
    File fin =      // input  file
    File fout =    // create an out file
     
    // Java FileInputStream class obtains input bytes from a file
    FileInputStream fis = new FileInputStream(fin);    
     
    // buffering characters so as to provide for the efficient reading of characters, arrays, and lines
    BufferedReader in = new BufferedReader(new InputStreamReader(fis));
     
    // declare an array in-line, ready for the sort
    String aLine;
    ArrayList al = new ArrayList ();
     
    int i = 0;
    while ((aLine = in.readLine()) != null) {
    // set the sort  for values is greater than 0
     
    Collections.sort(al);    // sorted content to the output  file
    {
    System.out.println(s);
                  
    }
     // close the 2 files
                          
    }
    }
     
    Add code as indicated in the comments.
    Note: Refer to this week's Individual assignment, "Week Three Analyze Assignment," and to Ch. 8, "IO," in OCP: Oracle® Certified Professional Java® SE 8 Programmer II Study Guide.
    Run and debug your modified program in NetBeans until it satisfies the requirements described above.
    Save your finalized JAVA file with a .txt extension.
    Submit your TXT file to the Assignment Files tab.

    Learn More
  8. 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
  9. PRG 421 Week 2 Individual Analyze Assignment Demonstrate the Coding to Produce Output to a File

    PRG 421 Week 2 Individual Analyze Assignment Demonstrate the Coding to Produce Output to a File

    Regular Price: $6.00

    Special Price $4.00

    PRG 421 Week 2 Individual Analyze Assignment Demonstrate the Coding to Produce Output to a File

    "Demonstrate the Coding to Produce Output to a File" text file
    For this assignment, you will analyze Java™ that presents instructional text on the console, accepts user input, and then creates a file based on that user input.
    Read the linked Java™ code carefully.
    Then, answer the following questions in a Microsoft® Word file:
    As you run the program in NetBeans the first time, at the prompt (the program will pause for input) type abc Return def Return ghi Ctrl+Shift+Del. What is the result?
    As you run the program in NetBeans the second time, at the prompt (the program will pause for input) type 123 Ctrl+Shift +Del. What is the result?
    What happens if the file Data.txt already exists when you run the program?
    What happens if the file Data.txt does not already exist when you run the program?

    Submit your Word file to the Assignment Files tab.

    /**********************************************************************
    *   Program:   FileOut 
    *    Purpose:    Demonstrate the coding to produce output to a file.  
    *   Programmer:   I am student         
    *   Class:       PRG/421r13, Java Programming II         
    *   Instructor:             
    *   Creation Date:   01/03/2018 
    *
    ***********************************************************************/
    package fileout;
    import java.io.*;

    public class FileOut {
    public static void main(String[] args) {

    InputStream istream;
    OutputStream ostream=null;
       // FileOutputStream creates an OutputStream that you can use to write bytes to a file.
    int c;                     // character stream 
    final int EOF = -1;                 // EOF indicator
    istream = System.in;

     
    // If the Data.txt file already exists, present its contents on the console.
    String fileName = "Data.txt";         // name of the file to open.
    String line = null;               // will reference one line at a time

    try {
    FileReader fileReader =        // FileReader reads text file
    new FileReader(fileName);         // reads in data from the file

    // always wrap FileReader in BufferedReader (to verify)
    BufferedReader bufferedReader =
    new BufferedReader(fileReader);

    System.out.println("Here are the contents of the current file named " + fileName + ":\n");
    while((line = bufferedReader.readLine()) != null) {
    System.out.println(line);        // verify / display what is read in by the program
    }  
    bufferedReader.close();         // close file

    }
    catch(FileNotFoundException ex) {       // coding to verify file can be opened
    System.out.println(           // if not open, error message to display
    "Unable to open file '" +
    fileName + "'");
    }
    catch(IOException ex) {           // exception, when there is an error in reading
    System.out.println(
    "Error reading file '"
    + fileName + "'");
    }

    // Now, let's construct a new file containing user input.
    System.out.println("\nType characters to write to file. After you finish, press Ctrl+Shift+Del to end.");
    File outFile = new File("Data.txt");    // create a new file

    try {                     // try block for EOF indicator
    ostream = new FileOutputStream(outFile);
    while ((c = istream.read()) != EOF)     // look for end of file in istream
    ostream.write(c);
    } catch (IOException e) {
    System.out.println("Error: " + e.getMessage());
    } finally {
    try {                     // try block for file error ñ file did not close

    istream.close();             // close input and output
    ostream.close();
    } catch (IOException e) {
    System.out.println("File did not close");
    }
    }
    }
    }

    Learn More
  10. 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

Items 21 to 30 of 222 total

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

Grid  List 

Set Ascending Direction
[profiler]
Memory usage: real: 15204352, emalloc: 14696096
Code ProfilerTimeCntEmallocRealMem