In: Computer Science
There are a lot of networking and network security jobs and every IT company has network engineers, admins, etc. Why and how do think understanding the OSI Model and Network Devices are important from a work standpoint? Looking for some original content.
In: Computer Science
Using Java Languse, Complete ArraySet.java down below by using (Array collection) :
package Homework3;
public class ArraySet extends ArrayCollection {
public ArraySet() {
}
public ArraySet(int size) {
super(size);
}
public boolean add(T element) {
// Complete your code here
return true;
}
}
ArrayCollection.java:
package Homework3;
public class ArrayCollection {
protected static final int DEFAULT_CAPACITY = 100;
protected T[] elements;
protected int numberOfElements;
public ArrayCollection() {
this(DEFAULT_CAPACITY);
}
public ArrayCollection(int size) {
elements = (T[]) new Object[size];
numberOfElements = 0;
}
public boolean isEmpty() {
return numberOfElements == 0;
}
public boolean isFull() {
return numberOfElements == elements.length;
}
public int size() {
return numberOfElements;
}
public String toString() {
String collection = "";
for (int i = 0; i < numberOfElements; i++)
collection += elements[i] + "\n";
return collection;
}
public boolean add(T element) {
// Complete your code here
return true;
}
public boolean remove(T target) {
// Complete your code here
return true;
}
public boolean removeAll(T target) {
// Complete your code here
return true;
}
public void removeDuplicate() {
// Remove any duplicated elements
}
public boolean equals(ArrayCollection that) {
// Return true if ArrayCollection are identical.
boolean result = true;
// Complete your code here.
return result && this.size() == that.size();
}
public int count(T target) {
// Return count of target occurrences
int c = 0;
// Complete your code here
return c;
}
public void merge(ArrayCollection that) {
// Merge that ArrayCollection into this ArrayCollection
// Complete your code here
}
public void enlarge(int size) {
// Enlarge elements[] with additional size
// Complete your code here
}
public void clear() {
// Remove all elements in the collection
}
//Note: Different from textbook, this implementation has no 'found'
and
'location' attributes.
// There is no find() method.
// There is a new methods findIndex().
public boolean contains(T target) {
// Return true if target is found
boolean found = false;
// Complete your code here
return found;
}
public int findIndex(T target) {
// Return index of target
int index = 0;
// Complete your code here
return index;
}
}
Homework3 class:
public class Homework3 {
public static void main(String[] args) {
ArrayCollection ac1 = new ArrayCollection(); // Calling
Default
Constructor
ArrayCollection ac2 = new ArrayCollection(2); // Calling
overloaded
constructor
ArraySet as1 = new ArraySet();
ac2.add("Apple");
ac2.add("Orange");
ac2.add("Lemon"); // This can't be added into ac2 as collection is
full
System.out.println(ac2.remove("Apple")); // This should return
true
System.out.println(ac2);
ac2.enlarge(10);
ac2.add("Watermelon");
System.out.println("Equals: " + ac1.equals(ac2));
as1.add("Avocado");
as1.add("Avocado"); // This will not be added, since the
collection is "set"
}
}
In: Computer Science
What the importance of Subnetting? Why do we need to learn Subnetting? How is it useful in day-to-day operations at a company? Looking for some original content.
In: Computer Science
The implementations of the methods addAll, removeAll, retainAll are omitted in the MyList interface. Implement these methods.
/** Adds the elements in otherList to this list.
* Returns true if this list changed as a result of the call
*/
public default boolean addAll(Collection<? extends E> c)
/** Removes all the elements in otherList from this list
* Returns true if this list changed as a result of the call
*/
public default boolean removeAll(Collection<?> c)
/** Retains the elements in this list that are also in
otherList
* Returns true if this list changed as a result of the call
*/
public default boolean retainAll(Collection<?> c)
Write a test program that creates two MyArrayLists, list1 and
list2, with the initial values {"Tom", "George", "Peter", "Jean",
"Jane"} and {"Tom", "George", "Michael", "Michelle", "Daniel"},
then perform the following operations:
■ Invokes list1.addAll(list2), and displays list1 and list2.
■ Recreates list1 and list2 with the same initial values, invokes
list1.removeAll(list2), and displays list1 and list2.
■ Recreates list1 and list2 with the same initial values, invokes
list1.retainAll(list2), and displays list1 and list2.
In: Computer Science
Java Programming :
Email username generator Write an application that asks the user to enter first name and last name. Generate the username from the first five letters of the last name, followed by the first two letters of the first name. Use the .toLowerCase() method to insure all strings are lower case. String aString = “Abcd” aString.toLowerCase(); aString = abcd Use aString.substring(start position, end position + 1) aString.substring(0, 3) yields the first 3 letters of a string If the last name is no more than five letters, use the entire name. If it is more than five letters, use the first 5 letters Print the email username you generated with @myCollege.edu appended
In: Computer Science
Create a simple Java class for a Month object with the following requirements:
This program will have a header block comment with your name, the
course and section, as well as a brief description of what the
class does.
All methods will have comments concerning their purpose, their
inputs, and their outputs
One integer property: monthNumber (protected to only allow values
1-12). This is a numeric representation of the month (e.g. 1
represents January, 2 represents February, etc.)
A constructor that takes no arguments, and sets the monthNumber
to 1.
Add a second constructor that takes in an integer argument to set
the initial monthNumber for the new Month object. Use data
protection to prevent the user from entering a number less than 1
or greater than 12. When a non-valid input is entered, throw a new
IllegalArgumentException.
A setMonth() method that takes an integer and uses data
protection to prevent the user from entering a number less than 1
or greater than 12. Also throw an IllegalArgumentException if an
illegal value is entered.
A getMonth() method that returns the monthNumber as an
integer.
Add a String array property that holds the values of the month
names (e.g. monthNames[3] would hold the value “March”). Remember,
you can leave the 0th index blank/null
Add a toString() method to use the monthNumber property to return
the name of the month as a String. Use the private global String
array with the names of the months in it to return the proper
String based on the monthNumber.
Add an equals() method that takes in a month object and returns a
boolean based on the values of each object’s monthNumber
Add a compareTo() method that takes in a month object and returns
a negative number if the called object is smaller than the passed
in object, a positive number if the called object is bigger than
the passed in object, and zero (0) if the two objects are
equivalent.
Create a simple program using Java that demonstrates the month object with the following requirements:
That creates a month object using the no argument
constructor.
A second month object is created using the constructor that takes
in an integer argument.
Additionally, use either a do or while loop to get the user to
enter a number between 1 and 12 using the setMonth() method on the
1st month object. The loop will continue until they enter a valid
number.
The program will display the month number for both of the objects
using the getMonth() method.
Display the month names using toString() for the months created,
and see whether they are the same or not.
Additionally, use the equals() method created above to show
whether the two months are equivalent to each other or not.
Use the compareTo() method created above to show which object is
the biggest.
Use appropriate try and catch statements to properly handle
erroneous input by the user.
In: Computer Science
Using Java, Complete the LinkedListBag down below by using the (LinkedListCollection.java:)
package Homework3;
public class LinkedListBag extends LinkedListCollection {
LinkedListBag() {
}
public T grab() {
T result;
Node cursor = head;
int rand = (int) (Math.random() * size());
// Some code in here..
result = cursor.getInfo();
remove(result);
return result;
}
}
LinkedListCollection.java:
package Homework3;
public class LinkedListCollection <T> {
protected Node<T> head = null;
public LinkedListCollection() {
}
public boolean isEmpty() {
return head == null;
}
public int size() {
int counter = 0;
Node<T> cursor = head;
while (cursor != null) {
cursor = cursor.getLink();
counter++;
}
return counter;
}
public String toString() {
Node<T> cursor = head;
String collection = "";
while (cursor != null) {
collection += cursor.getInfo() + "\n";
cursor = cursor.getLink();
}
return collection;
}
public boolean add(T element) {
// Insert at head
Node<T> node = new Node<T>(element);
// Code here
return true;
}
public boolean remove(T target) {
Node<T> cursor = head;
Node<T> previous = head;
while (cursor != null) {
// Code here
previous = cursor;
cursor = cursor.getLink();
}
return false;
}
public boolean removeAll(T target) {
Node<T> cursor = head;
Node<T> previous = head;
boolean found = false;
// Code here
return found;
}
public void removeDuplicate() {
// Remove any duplicated elements
// Code here
}
public boolean equals(LinkedListCollection that) {
// Return true if LinkedListCollection are identical.
boolean result = true;
Node<T> cursor_this = head;
Node<T> cursor_that = that.head;
while (cursor_this != null && cursor_that != null) {
if (!cursor_this.getInfo().equals(cursor_that.getInfo()))
result = false;
cursor_this = cursor_this.getLink();
cursor_that = cursor_that.getLink();
}
return result && this.size() == that.size();
}
public int count(T target) {
// Return count of target occurrences
int c = 0;
Node<T> cursor = head;
// Code here
return c;
}
public void merge(LinkedListCollection that) {
// Merge that LinkedListCollection into this
LinkedListCollection
if (that.head == null) return; // Nothing to merge
if (this == that) return; // Same list
// Code here
}
public void clear() {
// Remove all elements in the collection
}
public boolean contains(T target) {
// Return true if target is found
boolean found = false;
Node<T> cursor = head;
// Code here
return found;
}
}
Homework3 class:
public class Homework3 {
public static void main(String[] args) {
ArrayCollection ac1 = new ArrayCollection(); // Calling
Default
Constructor
ArrayCollection ac2 = new ArrayCollection(2); // Calling
overloaded
constructor
ArraySet as1 = new ArraySet();
ac2.add("Apple");
ac2.add("Orange");
ac2.add("Lemon"); // This can't be added into ac2 as collection is
full
System.out.println(ac2.remove("Apple")); // This should return
true
System.out.println(ac2);
ac2.enlarge(10);
ac2.add("Watermelon");
System.out.println("Equals: " + ac1.equals(ac2));
as1.add("Avocado");
as1.add("Avocado"); // This will not be added, since the
collection is "set"
}
}
In: Computer Science
----------------
Exercise 2: String Permutations
----------------
Create a program that takes a string from the command line and prints every permutation of that string. You may assume the string will contain all unique characters. You may print the permutations in any order, as long as you print them all.
----------------
Output:
----------------
$>./prog dog d do dog dg dgo o od odg og ogd g gd gdo go god
----------------
I have no idea on coding this. The files I need for this exercise are main.cpp, makefile, Executive.cpp, and Executive.h. So, will someone help me on this exercise? If so, then that will be great.
In: Computer Science
1) Write a python program that opens a file, reads
all of the lines into a list of strings, and closes the file. Use
the Readlines() method. Test your programing using the names.txt
file provided.
2) Convert the program into a function called loadFile, that
receives the file name as a parameter and returns a list of
strings.
3) Write a main routine that calls loadFIle three times to load the
three data files given into three lists. Then choose a random
element from the title list, two from the name list, and one from
the descriptor list to generate a name. Print the name be in the
form shown (you have to add the "the"):
title name name the descriptor
For example:
King Ludovicus Botolf the Bowman
Print the name to the screen.
Submit your python file (.py) to Sakai
Part 2: Writing Files (Optional Extra Credit 20 pts)
Modify the program to generate 10 names and store them in a
list.
Write a function, dumpFile that writes the list to a file called
"CharacterNames.txt" There should be one Character Name on each
line in the file.
Test the program to be sure it works
Im stumped at number 2
here is what i have for number 1
f = open('names.txt', 'r')
lines = f.readlines()
for line in range(len(lines)):
lines[line] = lines[line].rstrip()
print(lines)
f.close()
In: Computer Science
JAVA 1 PROGRAMMING QUESTION
In this program you will be writing a class that will contain
some methods. These will be regular methods (not static methods),
so the class will have to be instantiated
in order to use them.
The class containing the main method will
be provided and you will write the required methods and run the
supplied class in order to test those methods.
? Specifications
? The code for the testing class is given below. In order to test the code you write, you will need to rename this file as you have all of your program files, as outlined above. You will need to change the calls to the methods to reflect the class where your methods are located. Do not modify the logic in this file to make it fit your methods. Part of this problem is to meet the specifications of the test program.
The Methods to Write
displayLine()
displayMessage()
sumNumbers()
isGreater()
setBulb()
The Instance Variables
? Make all instance variables in the MethodPractice class private.
The MethodTest.java Class
? Be sure to rename this file as you do all of your files, as outlined above, and upload this file along with the MethodPractice file. You will also need to modify the method calls to match your class name for the MethodPractice class.
In: Computer Science
Write the following classes: Class Entry: 1. Implement the class Entry that has a name (String), phoneNumber (String), and address (String). 2. Implement the initialization constructor . 3. Implement the setters and getters for all attributes. 4. Implement the toString() method to display all attributes. 5. Implement the equals (Entry other) to determine if two entries are equal to each other. Two entries are considered equal if they have the same name, phoneNumber, and address. 6. Implement the compareTo (Entry other) method that returns 0 if the two entries have the same number, -1 if this.number is smaller than other.number, and + 1 if this.number is > other.number Class PhoneBook 1. Implement the class PhoneBook that has a city (String), type (String), entryList (an Array of Entry). Assume the array size = 10 2. Implement the constructors to initialize the city and type. 3. Implement the method addEntryToPhoneBook(Entry e) that adds an entry to the phone book. 4. Implement the method toString() that displays all attributes and all enties information of the phone book. 5. Implement the method displayAll() that displays all entries in the phone book. 6. Implement the method checkEntryByNumber(String number) that takes a number and returns the entry with that number if it exists. 7. Implement the method checkEntrisByName(String name) that takes a name, and returns an array of the entries that start with this name or letters. 8. Implement the method removeEntryFromPhoneBook (String number) that removes an entry from the array of entires in the phone book. Class TestPhoneBook 1. Create a phone book and initialize its attributes. 2. Add 5 entries to the phone book list using the method addEntryToPhoneBook() 3. Display all entries in the phone book. 4. Display the entry information for a given phone number if it exists. Give the appropriate message if it does not exist. 5. Display all entries starting with the letters "Abd" 6. Remove a specific entry from the phone book. Display the proper message if it was removed , or if it did not exist. 7. Sort and display the entries of the phone book (Bonus). Java NetBeans.
In: Computer Science
write mips assembly
mips assembly (x+a) (bx^2+cx+d) using the pesedo- code with loop ,program should claclute six T[i] and display aproper message about roots .the the program should store all T[i] as memory array
a = [1, 1, 1, 1, 1, 1];
b = [1, 2, 4, 8, 16, 32];
c = [-6, -4, -2, 2, 4, 6];
d = [-1, -3, -5, -7, -9, -11];
for (i=0 ; i<=6; i++) {
T[i] =-4 *b [i] * d[i] +c[i] * c[i];
if (T[i] <0)
display "tow roots are imaginary";
else
display "tow roots are real ";
}
In: Computer Science
In Java
We define BigNumber a number consisting of 0<N<21 elements.It can be negative in which case it will have a minus sign in front. Without modifying main method complete the methods add, subtract and reverse. Hints: class java.math.BigInteger would be very useful. For reverse method number== new StringBuffer(number).reverse().toString(); can be used however when you reverse a negative number the negative sign should stay in front. Thanks.
public class MD3 {
public static void main(String[] args)
{
BigNumber BigNumber1 = new BigNumber(args[0]);
BigNumber BigNumber2 = new BigNumber(args[1]);
BigNumber1.add(BigNumber2);
BigNumber1.display();
BigNumber1.reverse();
BigNumber1.display();
BigNumber2.subtract(BigNumber1);
BigNumber2.display();
BigNumber2.reverse();
BigNumber2.display();
}
class BigNumber {
private String number;
BigNumber(String str) { number = str; }
public void add(BigNumber sk) { /* ... */ }
public void subtract(BigNumber sk) { /* ... */ }
public void reverse() { /* ... */ }
public void display() {System.out.println(number);}
}
}
In: Computer Science
write java program that prompt the user to enter two numbers .the program display all numbers between that are divisible by 7 and 8 ( the program should swap the numbers in case the secone number id lower than first one please enter two integer number : 900 199 Swapping the numbers 224 280 336 392 448 504 560 616 672 728 784 840 896 i need it eclipse
In: Computer Science