Questions
What are the characteristics of cybersecurity policy?

What are the characteristics of cybersecurity policy?

In: Computer Science

1. How does Wireshark know the manufacturer of the device sending a packet? 2. Why is...

1. How does Wireshark know the manufacturer of the device sending a packet?

2. Why is a random interval added to the CSMA backoff and try again protocol?

3. Where are the routing tables for the backbone routers of the Internet calculated?

In: Computer Science

Task #1 Writing a Copy Constructor 1.Copy the files Address.java(Code Listing 8.1), Person.java(Code Listing 8.2),Money.java(Code Listing...

Task #1 Writing a Copy Constructor

1.Copy the files Address.java(Code Listing 8.1), Person.java(Code Listing 8.2),Money.java(Code Listing 8.3), MoneyDemo.java(Code Listing 8.4), andCreditCardDemo.java(Code Listing 8.5) from the Student CD or as directed by your instructor. Address.java, Person.java, MoneyDemo.java, and CreditCardDemo.java are complete and will not need to be modified. We will start by modifying Money.java.

2.Overload the constructor. The constructor that you will write will be a copy constructor. It should use the parameter Money object to make a duplicate Moneyobject, by copying the value of each instance variable from the parameter object to the instance variable of the new object.

Task #2 Writing the equals and toString methods

1.Write and document an equals method. The method compares the instance variables of the calling object with instance variables of the parameter object for equality and returns true if the dollars and the cents of the calling object are the same as the dollars and the cents of the parameter object. Otherwise, it returns false.

2.Write and document a toString method. This method will return a String that looks like currency, including the dollar sign. Remember that if you have less than 10 cents, you will need to put a 0 before printing the cents so that it appears correctly with 2 decimal places.

3.Compile, debug, and test by running the MoneyDemo program. You should get the following output:

The current amount is $500.00

Adding $10.02 gives $510.02

Subtracting $10.88 gives $499.14

$10.02 equals $10.02

$10.88 does not equal $10.02

Task #3 Passing and Returning Objects

1.Create theCreditCardclass according to the UML diagram. It should have data fields that include an owner of type Person, a balance of type Money, and a creditLimit of type Money.

2.It should have a constructor that has two parameters, a reference to a Person object to initialize the owner and a reference to a Money object to initialize the creditLimit. The balance can be initialized to a Money object with a value of zero. Remember you are passing in objects (passed by reference), so you are passing the memory address of an object. If you want your CreditCard to have its own creditLimit and balance, you should create a new object of each using the copy constructor in the Moneyclass

3. It should have accessor methods to get the balance and the creditLimit. Since these are Money objects (passed by reference), we don’t want to create a security issue by passing out addresses to components in our CreditCard class, so we must return a new object with the same values. Again, use the copy constructor to create a new object of type Money that can be returned.

4. It should have an accessor method to get the information about the owner, but in the form of a String that can be printed out. This can be done by calling the toString method for the owner (an instance of the Person class).

5. It should have a method that will charge to the CreditCard by adding the amount passed in the parameter to the balance, but only if it will not exceed the creditLimit. If the creditLimit will be exceeded, the amount should not be added, and an error message can be printed to the console.

6. It should have a method that will make a payment on the CreditCard by subtracting the amount passed in the parameter from the balance.

7. Compile, debug, and test it out completely by running the CreditCardDemo program.

8. You should get the output:

Diane Christie, 237J Harvey Hall, Menomonie, WI 54751

Balance: $0.00

Credit Limit: $1000.00

Attempting to charge $200.00

Charge: $200.00 Balance: $200.00

Attempting to charge $10.02

Charge: $10.02 Balance: $210.02

Attempting to pay $25.00

Payment: $25.00 Balance: $185.02

Attempting to charge $990.00

Exceeds credit limit

Balance: $185.02

Code Listing 8.1 (Address.java)

/** This class defines an address using a street,

city, state, and zipcode. */

public class Address

{

// The street number and name

private String street;

// The city in which the address is located

private String city;

// The state in which the address is located

private String state;

// The zip code associated with the city and street

private String zip;

/**

Constructor

@param road Describes the street number and name.

@param town Describes the city.

@param st Describes the state.

@param zipCode Describes the zip code.

*/

public Address(String road, String town, String st, String zipCode)

{

street = road;

city = town;

state = st;

zip = zipCode;

}

/**

The toString method

@return Information about the address.

*/

public String toString()

{

return (street + ", " + city + ", " + state + " " + zip); } }

Code Listing 8.2 (Person.java)

/**

This class defines a person by name and address.

*/ public class Person

{

// The person's last name private String lastName;

// The person's first name private String firstName;

// The person's address private Address home;

/** Constructor

@param last The person's last name.

@param first The person's first name.

@param residence The person's address.

*/

public Person(String last, String first, Address residence)

{ lastName = last;

firstName = first;

home = residence; }

/**

The toString method @return Information about the person.

*/ public String toString()

{

return(firstName + " " + lastName + ", " + home.toString()); } }

Code Listing 8.3 (Money.java)

/** This class represents nonnegative amounts of money. */

public class Money

{

// The number of dollars private long dollars;

// The number of cents private long cents;

/** Constructor

@param amount The amount in decimal format. */

public Money(double amount)

{

if (amount < 0)

{

System.out.println("Error: Negative amounts " + "of money are not allowed.");

System.exit(0);

}

else { long allCents = Math.round(amount * 100); dollars = allCents / 100; cents = allCents % 100; } }

// ADD LINES FOR TASK #1 HERE

// Document and write a copy constructor

/**

The add method @param otherAmount The amount of money to add. @return The sum of the calling Money object and the parameter Money object. */

public Money add(Money otherAmount)

{ Money sum = new Money(0);

sum.cents = this.cents + otherAmount.cents;

long carryDollars = sum.cents / 100;

sum.cents = sum.cents % 100;

sum.dollars = this.dollars + otherAmount.dollars + carryDollars; return sum; }

/** The subtract method @param amount The amount of money to subtract. @return The difference between the calling Money object and the parameter Money object. */

public Money subtract (Money amount)

{ Money difference = new Money(0);

if (this.cents < amount.cents)

{

this.dollars = this.dollars - 1;

this.cents = this.cents + 100;

}

difference.dollars = this.dollars - amount.dollars;

difference.cents = this.cents - amount.cents;

return difference; }

/** The compareTo method

@param amount The amount of money to compare against.

@return -1 if the dollars and the cents of the calling object are less than the dollars and the cents of the parameter object. 0 if the dollars and the cents of the calling object are equal to the dollars and cents of the parameter object. 1 if the dollars and the cents of the calling object are more than the dollars and the cents of the parameter object. */

public int compareTo(Money amount)

{ int value;

if(this.dollars < amount.dollars) value = -1;

else if (this.dollars > amount.dollars) value = 1;

else if (this.cents < amount.cents) value = -1;

else if (this.cents > amount.cents) value = 1;

else value = 0; return value; }

// ADD LINES FOR TASK #2 HERE

// Document and write an equals method

// Document and write a toString method }

Code Listing 8.4 (MoneyDemo.java)

/** This program demonstrates the Money class. */

public class MoneyDemo

{

public static void main(String[] args)

{

// Named constants

final int BEGINNING = 500; // Beginning balance

final Money FIRST_AMOUNT = new Money(10.02);

final Money SECOND_AMOUNT = new Money(10.02);

final Money THIRD_AMOUNT = new Money(10.88);

// Create an instance of the Money class with

// the beginning balance.

Money balance = new Money(BEGINNING);

// Display the current balance. System.out.println("The current amount is " + balance.toString());

// Add the second amount to the balance

// and display the results.

balance = balance.add(SECOND_AMOUNT); System.out.println("Adding " + SECOND_AMOUNT + " gives " + balance.toString());

// Subtract the third amount from the balance

// and display the results.

balance = balance.subtract(THIRD_AMOUNT);

System.out.println("Subtracting " + THIRD_AMOUNT + " gives " + balance.toString());

// Determine if the second amount equals

// the first amount and store the result. boolean equal = SECOND_AMOUNT.equals(FIRST_AMOUNT);

// Display the result.

if(equal)

{

// The first and second amounts are equal.

System.out.println(SECOND_AMOUNT + " equals " + FIRST_AMOUNT);

}

else

{

// The first and second amounts are not equal. System.out.println(SECOND_AMOUNT + " does not equal " + FIRST_AMOUNT); }

// Determine if the third amount equals

// the first amount and store the result.

equal = THIRD_AMOUNT.equals(FIRST_AMOUNT);

// Display the result.

if(equal)

{

// The third and first amounts are equal.

System.out.println(THIRD_AMOUNT + " equals " + FIRST_AMOUNT);

}

else

{

// The third and first amounts are not equal.

System.out.println(THIRD_AMOUNT + " does not equal " + FIRST_AMOUNT); } } }

Code Listing 8.5 (CreditCardDemo.java)

/** This program demonstrates the CreditCard class. */

public class CreditCardDemo

{

public static void main(String[] args) {

// Named constants final Money CREDIT_LIMIT = new Money(1000);

final Money FIRST_AMOUNT = new Money(200);

final Money SECOND_AMOUNT = new Money(10.02);

final Money THIRD_AMOUNT = new Money(25);

final Money FOURTH_AMOUNT = new Money(990);

// Create an instance of the Person class. Person owner = new Person("Christie", "Diane", new Address("237J Harvey Hall", "Menomonie", "WI", "54751"));

// Create an instance of the CreditCard class. CreditCard visa = new CreditCard(owner, CREDIT_LIMIT);

// Display the credit card information.

System.out.println(visa.getPersonals()); System.out.println("Balance: " + visa.getBalance()); System.out.println("Credit Limit: " + visa.getCreditLimit()); System.out.println(); // To print a new line

// Attempt to charge the first amount and

// display the results.

System.out.println("Attempting to charge " + FIRST_AMOUNT);

visa.charge(FIRST_AMOUNT);

System.out.println("Balance: " + visa.getBalance());

System.out.println();

// To print a new line

// Attempt to charge the second amount and

// display the results.

System.out.println("Attempting to charge " + SECOND_AMOUNT);

visa.charge(SECOND_AMOUNT);

System.out.println("Balance: " + visa.getBalance());

System.out.println(); // To print a new line

// Attempt to pay using the third amount and

// display the results.

System.out.println("Attempting to pay " + THIRD_AMOUNT);

visa.payment(THIRD_AMOUNT);

System.out.println("Balance: " + visa.getBalance());

System.out.println();

// To print a new line

// Attempt to charge using the fourth amount and

// display the results.

System.out.println("Attempting to charge " + FOURTH_AMOUNT);

visa.charge(FOURTH_AMOUNT);

System.out.println("Balance: " + visa.getBalance());

} }

In: Computer Science

Exceptional task in c++ OOP: 1. Create three exceptions classes / structures, for division by zero,...

Exceptional task in c++ OOP: 1. Create three exceptions classes / structures, for division by zero, first second for out of range, third for reading file that doesn't exist. Secure given code with self-made exceptions

In: Computer Science

In Lecture 8(ArrayList, Generics) , we discussed about creating a MyStack<E> class using the ArrayList<E> class...

  1. In Lecture 8(ArrayList, Generics) , we discussed about creating a MyStack<E> class using the ArrayList<E> class that has the stack methods ( isEmpty(), getSize(), peek(), pop(), push(Object o), and toString( ) ) as shown in the following:

public class MyStack<E> {

private ArrayList<E> list = new ArrayList<>();

public int getSize() {

    return list.size();

}

public E peek() {

    return list.get(getSize() - 1);

}

public void push(E o) {

    list.add(o);

}

public E pop() {

    E o = list.get(getSize() - 1);

    list.remove(getSize() - 1);

    return o;

}

public boolean isEmpty() {

    return list.isEmpty();

}

@Override

public String toString() {

    return "stack: " + list.toString();

}

}

For this exercise, rewrite the MyStack <E> to the GenericStack<E> class that extends from ArrayList<E>.

import java.util.ArrayList;
import java.util.Iterator;

public class A6Q2 {
   public static void main(String[] args) {
/* After building your GenericStack from the ArrayList, add codes here to build the two Stacks
* (String and Integer) here
*/      
      
      
   }

   // Build a static class GenericStack<E> extends ArrayList

   static class GenericStack<E> extends ArrayList<E> {
  
         
         
   }
   }
Since this is a GenericStack<E> class, show that you can build a String (names) and Integer (Integer) stack using the same generic class.

In java please. Thank You

In: Computer Science

THIS PROGRAM I HAVE MADE UP CHOOSES A RANDOM STORY AND IS IN MAD LIBS FORMAT....

THIS PROGRAM I HAVE MADE UP CHOOSES A RANDOM STORY AND IS IN MAD LIBS FORMAT.

IM HAVING A DIFICULT TIME FORMING A ALGORITHIM FOR THE PROGRAM. if you coukd develop a algorithim it will be greatly appreciated.

Thank you,

# Dillon Montefusco, A, B

# need to write up a Mad Libs story itself.

# looping input where it prompts for a type of word

# need to write entire scripts (stories)

# use random to choose a story, so the user cannot read it and can enjoy with his friends also the story.



import random as r # for the story randomize agent

ri = r.randint



def okt(b): # octal number converter (ALL RIGHTS RESERVED, THIS FUNCTION IS OFF THE INTERNET)

n = int(b)

r = ''

while n > 0:

r = str(n % 8) + r

n //= 8

if r: return r

return '0'



def get_story(): # This is the story randomize agent

return ri(1, 0o3)



def word_prompt(pos): # part of speech

"""Function takes a word type (part of speech) and returns the word to be inserted in the mainString."""

word = input("Enter a "+str(pos)+": ")

if pos == 'name' or pos == 'male' or pos == 'female' or pos == 'city':

return word.title()

else:

return word.lower()



# THIS IS STORY 01 OF 20

def story01():

wp = word_prompt

story01 = "While going down the "+str(wp('name'))+" Bridge to "+str(wp('city'))+", something out-of-the-ordinary happened... \n\

a bunch of "+str(wp('plural noun'))+" were "+str(wp('verb'))+" over the traffic! It was pretty wierd,\n\

and definitely a "+str(wp('adjective'))+" sight to see, but I guess that's one way to beat the "+str(wp("adjective"))+" traffic. \n\

Man, I wish I could do the same."

return story01


def story02():

wp = word_prompt

story02 = "Homeboy "+str(wp('male'))+" pulled up to the "+str(wp('place'))+" and bought "+str(wp('number'))+" lottery tickets. \n\

Litte did he know, one of the tickets was a "+str(wp('adjective'))+" winner! \nOnce he checked the tickets, homeboy got so happy! \n\

Matter of fact, he was so happy that he "+str(wp('verb'))+" all the way home, \nbut dropped the winning ticket on the way. Long story short, he never got his money. \n\

Sucks to suck, doesn't it?"

return story02


def story03():

wp = word_prompt

story03 = "Back in the olden times there was a "+str(wp('mystical creature'))+" named "+str(wp('name'))+" that \

lived in a "+str(wp('adjective'))+" cave. \nIt was hella dusty in there, and the poor homie had \

trouble breathing. \nBut fear no more, because a "+str(wp('adjective'))+" wizard came through and pulled up with a \nmagical "+str(wp('item'))+" that \

cleaned up the place better than a swiffer sweeper duster! \nIf it wasn't for "+str(wp('male'))+" the Wizard, \

the "+str(wp('mystical creature'))+" would've gotten asthma. \nToo bad inhalers weren't invented back then."

return story03


  

# STORY DETERMINER

def story_determiner(count):

count = count

sn = get_story()

story_random = input("Get a random story?: ")

if story_random.lower() == "no":

story_prompt = input("Enter story number: ")

if story_prompt == "1" or story_prompt == "01":

input(story01())

repeat()

if story_prompt == "2" or story_prompt == "02":

input(story02())

repeat()

if story_prompt == "3" or story_prompt == "03":

input(story03())

repeat()

else:

input("Sorry, I can't recognise that story number!")

if count > 3: # hidden message counter

print("Have you really messed up", okt(count), "times!?")

story_determiner(count + 1)

elif story_random.lower() == "yes":

if sn == 1:

input(story01())

repeat()

elif sn == 2:

input(story02())

repeat()

elif sn == 3:

input(story03())

else:

input("Sorry, feature not available in the educational version!")

exit()



# OVERALL PROGRAM LOOP

def repeat():

a = input("Would you like to do another?: ")

if a.lower() == 'yes':

story_determiner(0)

elif a.lower() == 'no':

input("Thanks for playing! Press enter to close.")

else:

print("Bruh, how about you answer the question, eh?")

repeat()



story_determiner(0) # This line begins the program execution

In: Computer Science

Scheduling Algorithms Part 1 First Come First Serve Consider the following processes along with their burst...

Scheduling Algorithms

Part 1

First Come First Serve

Consider the following processes along with their burst time (in Calculate the average waiting time if the processes arrive in the following order

Process

Burst Time in Ms

P1

20

P2

10

P3

5

Calculate the average waiting time if the processes arrive in the following order

(i)P1, P2, P3

(ii)P2, P3, P1

(i) Case 1: Consider a case if processes P1, P2, P3 arrive at the same time say 0 ms in the system in the order P1, P2, P3. The arrival of processes is represented in the Gantt chart as shown below.

Gantt chart

P1

P2

P3

                                          20                                             30                                            35

Process

Waiting Time

Turnaround Time

P1

0

20

P2

20

30

P3

30

35

Therefore, average waiting time =

Turnaround Time =

Case 2: Processes arrive in order P1, P2, P3, let us assume at 0 ms, 2 ms and 4 ms, respectively.

Arrival Time: Time at which the process arrives in the ready queue.

Process

Burst Time

Arrival Time

P1

20

0

P2

10

2

P3

5

4

Gantt chart: Draw the Gantt Chart

Waiting time for process P1 = 0 ms

Waiting time for process P2 = 20 ms – 2 ms = 18 ms

Waiting time for process P3 = 30 ms- 4 ms = 26 ms

Calculate the average waiting time

Calculate the Turnaround Time

In: Computer Science

write the pseudocode to process these tasks: From the random module import randint to roll each...

write the pseudocode to process these tasks:

  1. From the random module import randint to roll each die randomly
    1. # in pseudocode, import a random function
    2. # the name is helpful for the next M5-2 assignment
  2. Define a class called Dice
    1. In Python, the syntax has a colon after it: class Dice():
    2. In pseudocode, you can specify it generally or be specific
  3. Under the class declaration, list the attributes. Here are some tips:
    1. # attributes are what we know about a single die (dice is plural)
    2. # self is the first attribute in Python and must always appear first
    3. # add a num_sides attribute and to set it to 6 for the 6 sides on the dice
  4. Define a method for roll(self)
    1. # it describes what happens when we roll a single die
    2. # in the code, it will look like this example
      1. def __init__(self, dice_sides=6):
      2. # in pseudocode, we do not worry about the punctuation
      3. # just list it as part of your logic
  5. Under roll(self), return a random int value between 1 and self.dice_sides
  6. Save this file as M5Lab1ii - you can save it as MS Word or a text file.

For the second module, write the pseudocode to complete these tasks:

  1. In the same M5Lab1ii file, start a second module below the first module.
  2. From a new dice module, import our Dice class
  3. Create a 6-sided die by using assignment # for example: dice = Dice()
  4. Create an empty results list
  5. Write a for statement that takes each roll_num in range() and rolls it 100 times
  6. Set the value of result to dice.roll()
  7. For each roll and append it to the results list using your list’s name and .append() with the variable for each dice roll inside the parameters for append(). For example:
    1. # yourlistname.append(result)
  8. Refer to the name of your list within the print() parameter to print the results.
  9. 100 dice rolls for the values 1-6 appear in a list on the Python shell.
  10. Save the two modules in M5Lab1ii - you can save it as MS Word or a text file.

In: Computer Science

Classless Subnetting 200.30.0.0/16 Group Blocks Needed Addresses Per Block Host Bits CIDR Total Addresses Increment #...

Classless Subnetting

200.30.0.0/16

Group

Blocks

Needed

Addresses Per Block

Host Bits

CIDR

Total Addresses

Increment #

Start Address

End Address

A

16

512

B

128

64

C

32

1024

D

512

4

E

256

16

Group C

Block

Start (Subnet ID)

1st Address

Last Address

End (Broadcast)

1

2

3

4

5

In: Computer Science

In Python, there are different sorting algorithms. Selection Sort, Bubble Sort and Insertion Sort. • Write...

In Python, there are different sorting algorithms.

Selection Sort, Bubble Sort and Insertion Sort.


• Write a Pseudo code first for each of these sort methods.  


• After writing the pseudo code write python code from the pseudo code.


• Upload the pseudo code and Python code for each of the three algorithm mentioned.

In: Computer Science

C++ Problem Use the following global structure declaration as an example only. You will need to...

C++ Problem

Use the following global structure declaration as an example only. You will need to create your own data structure based on a database of your own design. For example, movies in a video collection, houses for sale, business appointments, etc. Your data structure should include a minimum of four fields. At least one field should be string, and one field should be numeric (int, or double).  

Example Only

struct VEHICLE

{

string make;

string model;

int year;

int miles;

double price;

};

In main() create an array that has room that has room for 50 database records(i.e. an array of structures). Your program should support the following general menu choices –

  1. Add Items (i.e. Add Vehicle)

  2. List All Items (i.e. Show All Vehicles)

      Q. Quit

Your program should implement a separate function to add items, and display items. For example,

void addVehicle(VEHICLE arr[], VEHICLE addItem, int pos);

adds vehicle item that is a structure to the pos position in the dealer array.

void displayAll(VEHICLE arr[], int n);

displays all vehicle info for the number of vehicles stipulated (i.e. 0 to n-1)

Notes: You are welcome to create one or more additional functions to support your program. For example, showMenu, or getMenuChoice might be useful. Also, you might create a function to collect information, for example, a getVehicleInfo function could populate a structure that was passed ByRef. Please note, in the example above, addVehicle is passed a structure variable in addition to the array. In this approach, addVehicle should take the passed structure variable and add it to the dealer array at the position stipulated. You will need to use an index variable that your program can use to keep track of the next available position in the dealer array. This index variable should be local to main(). So NO global variables please. You will need to update or increment this index variable everytime you call addVehicle. You can use this variable when calling addVehicle, and displayAll.

In: Computer Science

Create a system which ends when the user wants it to. After a user has used...

Create a system which ends when the user wants it to. After a user has used this system, there is an option of another user using it. The system should ask whether you want to continue or not. Below is a sample of the input/output system.

Are you a student or a librarian?
Hit 1 for student and 2 for librarian.
$1
Enter Name: $William
How many books do you want to take?
$4
What books do you want to take?
Enter book ISBN no(Ex: 242424) // Let's assume we have a 6 digit ISBN number for this project. Put any number to test //your system.
$454092

$535212

$676685

$128976
William borrowed 4 books.
Hit 1 to continue 0 to end system
$1
Are you a student or a librarian?
Hit 1 for student and 2 for librarian.
$2
Enter Name: $Miss Benny
0 Lisa borrowed 1 books //format: student_id Student_name "borrowed" number_of_books "books"
1 William borrowed 4 books
Type student id for more info.
$ 0
Lisa borrowed 1 books
235633
Hit 1 to continue 0 to end system
$0

//There needs to be an array for studentid, student name, isbn index start #, isbn index end #, and libarian name

This is also C++,

If you need further information please specify in the comments and I will edit the problem as needed. I need this information ASAP please.

The $ represents inputs made by the "user"

In: Computer Science

What are the phases in a traditional project life cycle? How does a project life cycle...

What are the phases in a traditional project life cycle? How does a project life cycle differ from a product life cycle? Why does a project manager need to understand both?

In: Computer Science

Briefly explain the differences between functional, matrix, and project organizations. Describe how each structure affects the...

Briefly explain the differences between functional, matrix, and project organizations. Describe how each structure affects the management of the project.

In: Computer Science

Write in python: Go through the visualization of the Selection Sort, Bubble Sort and Insertion Sort....

Write in python:

Go through the visualization of the Selection Sort, Bubble Sort and Insertion Sort.

Write a Pseudo code first for each of these sort methods. After writing the pseudo code write python code from the pseudo code.

In: Computer Science