Examine the following shell script and describe its function line-by-line:
#!/bin/bash
echo -e "Which file would you like to copy> --> \c"
echo -e "Which file would you like to copy? --> \c?"
read FILENAME
mkdir /stuff || echo "The /stuff directory could not be created." && echo "The /stuff directory could not be created."
cp -f $FILENAME /stuff && echo "$FILENAME was successfully copied to /stuff"
In: Computer Science
Modifiability comes in many flavors and is known by many names. Find one of the IEEE or ISO standards dealing with quality attributes and compile a list of quality attributes that refer to some form of modifiability. Discuss the differences.
In: Computer Science
We see that data structures, collections, and abstract data
types are closely related concepts.
Objects that are contained within these entities are typically
called items or elements.
From the object-oriented perspective, data structures have both
private data and public behaviors.
The behaviors define data structures in an abstract, implementation
independent manner.
Other equivalent terms used for behaviors are operations, methods,
public interface, and usage interface. In this discussion, we
explore the primary behaviors needed to use data structures.
- Remove an item
- Replace an item
Discuss these behaviors.
In: Computer Science
AES
(a) Give the names of at least two finalist ciphers, besides Rijndael, of the AES competition.
(b) What are the main four layers (steps within each round) of the AES and what is their role in the encryption?
(c) The recommended key sizes for the AES are 128, 192 and 256 bits. How many rounds of AES should be done for each of these sizes?
(d) DES has 8 different S-boxes, AES has only 1. State briefly negative security consequences of these two choices, separately for DES and AES.
(e) In order to strengthen AES one could increase the number of rounds and/or increase the size of the block. Which of the three options would be best for this purpose and why?
In: Computer Science
The default constructor initializes the first name to “john”, the last name to “Doe”, and the birth day and hired day to the default date (1/1/1960).
In addition to the constructors, the class has the following public instance methods:
NAME: <lastName + “, “ + firstName>
ID NUMBER: <Id-Number>
BIRTH DAY: <string-birth-day>
DATE HIRED: < string-date-hired >
If gross pay is greater than or equal to 1000, 20% of the gross pay;
If 800 <= gross pay < 1000, 18% of gross pay
If 600 <= gross pay < 800, 15% of gross pay
Otherwise, 10 % of the gross pay.
GROSS PAY: <gross-pay>
TAX DEDUCTION: <tax-deduction>
NET PAY: <Net-pay>
John Doe 111111 10/25/1990 11/15/2010 750.00
And then output its personal and pay information (by calling the instance methods getPInfoString( ) and getPayInfoString( )).
excercise 03 is the code written below
import java.util.Scanner;
class Date {
private int month; // to hold the month (1 – 12)
private int day; // to hold the day (1 – 31)
private int year; // to hold the year 1960 - 2019
static final String[] monthList = { " ", "January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December" };
public Date() // default constructor
{
month = 1;
day = 1;
year = 1960;
}
public Date(int newMonth, int newDay, int newYear) // constructor
{
month = newMonth;
day = newDay;
year = newYear;
checkDate();
}
public void inputDate(Scanner scan) // use the Scanner object to read the month and the day
{
month = scan.nextInt(); // read the month
day = scan.nextInt(); // read the day
year = scan.nextInt(); // read the year
checkDate();
}
private void checkDate() // to validate the month and the day
{
final int[] daysPerMonth = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if ((month < 1) || (month > 12) || (day < 1) || (day > daysPerMonth[month]) || year < 1960 || year > 2016) {
System.out.println("Invalid date");
System.exit(0);
}
}
String getStringDate() // returns the string consisting of the month followed by the day
{
return (monthList[month] + " " + day+" "+year);
}
public int getMonth() // to return the month
{
return (month);
}
public int getDay() // to return the day
{
return (day);
}
public int getYear() // to return year
{
return (year);
}
public boolean equalTo(Date obj) {
return (month == obj.month && day == obj.day && year == obj.year);
}
//which Date object is greater
public static boolean isGreaterThan(Date obj1, Date obj2) {
if(obj1.year > obj2.year)
return true;
else if(obj1.year == obj2.year) {
if(obj1.month > obj2.month)
return true;
else if(obj1.month == obj2.month) {
if(obj1.day > obj2.day)
return true;
}
}
return false;
}
}
public class Test {//driver class
/*------- Program is executed with a month and a day as command line arguments -----*/
public static void main(String[] args) {
Date defaultDate = new Date(); // to hold today’s month and day
System.out.println(defaultDate.getStringDate());
/*------------------------------------ read today’s month and day ---------------------*/
Date today = new Date(3, 25, 2016); // set Today's date
System.out.println("Todays day is:\t"+today.getStringDate());
/*------------------------------------ read dueDate month and day ---------------------*/
Date dueDate = new Date();
Scanner input = new Scanner(System.in);
System.out.println("Enter today’s month, day and year:");
dueDate.inputDate(input);
/*------------------------------------ compare today and dueDate ---------------------*/
if (today.equalTo(dueDate))
System.out.println("Your project is on time");
else {
if(Date.isGreaterThan(today, dueDate))
System.out.println("Your project is late");
else
System.out.println("Your project is early");
}
/*------------------------------------ inavlid date ---------------------*/
Date invalidDate = new Date(25, 4, 2000);
}
}
In: Computer Science
This is C++
there are intruction and descriptions. Please give me the answer
because I understand the concept, but don't know how to put in the
actual problem yet.
Instructions and Assumptions
Declare and implement the three functions described
below. Your declarations should go in AnyList.h. Your definitions
should go in Functions.cpp.
For all of these functions, assume the list contains at least three
elements. No need to consider the empty list cases.
The Functions
1. Overload the insertion operator as a friend
function of AnyList. It should print only the first and last
element.
For example, if the list were [1, 3, 5, 7], it should print "1
7".
2. Overload the > operator as a non-member function. It should
compare two AnyList objects. Given two lists, ListA and ListB,
ListA > ListB if the largest element of ListA is greater than
the largest element of ListB.
For example, if ListA = [1, 2, 5] and ListB = [3, 4, 3], then ListA
> ListB because 5 > 4.
3. Write a function called findAndModify that is a member function
of AnyList. It should take one parameter - an integer called key.
It should return a boolean value, which will be true if the key was
found and false otherwise. This function should not print any error
messages.
The function should search the list for key. If it finds key, it
should add one node to the beginning of the list whose data should
be key + 10.
Examples:
Assume the list is [3, 5, 20, 8, 5, 20]
findAndModify(3) --> return true; resulting list is [13, 3, 5,
20, 8, 5, 20]
findAndModify(5) --> return true; resulting list is [15, 15, 3,
5, 20, 8, 5, 20]
findAndModify(100) --> return false; resulting list is [3, 5,
20, 8, 5, 20]
AnyList.h/////////
/////////////////////////////////////////////////////
// Put your name on this file.
// Put the declarations for the functions where indicated.
// Do NOT add any other functions to DoublyList.
// Do NOT change any other functions in this file.
// Turn in this file
////////////////////////////////////////////////////
#ifndef ANYLIST_H
#define ANYLIST_H
#include<iostream>
#include <string> //Need
to include for NULL
class Node
{
public:
Node() : data(0), next(nullptr) {}
Node(int theData, Node* newNext)
: data(theData),
next(newNext) {}
Node* getNext() const { return next; }
int getData() const { return data; }
void setData(int theData) { data = theData;
}
void setNext(Node* newNext) { next = newNext;
}
~Node() {}
private:
int data;
Node* next;
};
///////////////////////////////
// Declare Functions Here, if needed
//////////////////////////////
class AnyList{
public:
///////////////////////////////
// Declare Functions Here, if
needed
//////////////////////////////
/////////////////////////////////
// Do not modify anything below //
////////////////////////////////
AnyList();
AnyList(int* elems, int numElem);
void destroyList();
~AnyList();
private:
Node* first;
int count;
};
#endif
AnyList.cpp///////
/////////////////////////////////////////////
// DO NOT MODIFY THIS FILE //
/////////////////////////////////////////////
#include "AnyList.h"
//constructor
AnyList::AnyList(){
first = nullptr;
count = 0;
}
AnyList::AnyList(int* elems, int numElem) {
first = new Node(elems[0], nullptr);
Node* last = first;
for (int i = 0; i < numElem; i++) {
last->setNext(new
Node(elems[i], nullptr));
last =
last->getNext();
}
count = numElem;
}
void AnyList::destroyList(){
Node* temp = first;
while (first != nullptr){
first =
first->getNext();
delete temp;
temp = first;
}
count = 0;
}
//destructor
AnyList::~AnyList()
{
destroyList();
}
Functions.cpp/////////
#include "AnyList.h"
///////////////////////////////////////
// Put your name in this file
// Implement your functions in this file
// Submit this file
/////////////////////////////////////
////////////////////////////////////////
// Definition of Function 1 goes here
//////////////////////////////////////
////////////////////////////////////////
// Definition of Function 2 goes here
//////////////////////////////////////
////////////////////////////////////////
// Definition of Function 3 goes here
//////////////////////////////////////
Main,cpp///////
///////////////////////////////////////
// Use this file to test your code
// Don't submit this file
/////////////////////////////////////
#include "AnyList.h"
#include <iostream>
using namespace std;
int main() {
int elems[] = { 1, 2, 3, 4, 5, 6,
7, 8 };
AnyList testList(elems, 8);
return 0;
}
In: Computer Science
Briefly explain two modes to convey information in the SNMP protocol.
In: Computer Science
In: Computer Science
Convert your "To Do List" application to use Hibernate in order to save its data. Then add a web UI, so that it runs on the Tomcat web server. You will have to add JSP code for each of the web pages (show to-do list, add a to-do item, delete a to-do item). Your to-do-list application should already be well structured, separating the back-end from the front-end, so that adding a web UI is just a matter of adding a new front-end which would call the existing back-end.
Here's my code so far:
package assignment1;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.Random;
public class assignment4 {
public static void main(String[] args) {
ArrayList_Op();
LinkedList_Op();
HashTable_Op();
}
private static void ArrayList_Op() {
ArrayList<Integer> arr_list = new ArrayList<>();
Random rand = new Random();
for(int i=0; i<200000; i++)
{
arr_list.add(rand.nextInt(200000));
}
for(int i=0; i<200000; i++)
{
arr_list.remove(0);
}
}
private static void LinkedList_Op() {
LinkedList<Integer> list = new
LinkedList<Integer>();
Random rand = new Random();
for(int i=0; i<200000; i++)
{
list.add(rand.nextInt(200000));
}
for(int i=0; i<200000; i++)
{
list.remove(0);
}
}
private static void HashTable_Op() {
Hashtable<Integer, Integer> hash = new
Hashtable<>();
Random rand = new Random();
for(int i=0; i<200000; i++)
{
hash.put(i, rand.nextInt(200000));
}
for(int i=0; i<200000; i++)
{
hash.remove(i);
}
}
}
In: Computer Science
In: Computer Science
1. I need a java program that prints the following rows of arrays, like shown
[3,5,6
7, 61, 71,
9, 99, 999,
4, 1, 0]
2. I also need a program that prints the sum of all the arrays
3. and a third program that only prints the elements from row one.
Thanks!
In: Computer Science
Write a program that repeatedly generates a random integer in the range [1, 100], one integer at a time, and displays the generated numbers on the screen according to the following rules:
1
5
31
69
87
43
31
In: Computer Science
A formula with a positive integer (less than 32 bits) and a
positive decimal (number with decimal points) is expressed in the
median formula. Change the given median to postfix and write a
program that outputs the results of the calculation.
operand ::= positive integer or positive error
Positive integer ::= A number expressed as less than 32 bits
consisting of 0 to 9.
Positive integer representation of 0, 0100, 00934, 1056, 65535 is
allowed
Positive decimal ::= Positive integer and decimal point (.) and
positive integer number
A positive decimal representation of 0, 000.0100, 0.0001054,
0065.535, 1000.32 is allowed
Operator ::= '+', '-', '*', '/', '^', 'u' means unary operator -
(negative sign)
The rest are all binary operators.
(1) A median formula containing a positive integer and a decimal
number is entered.
(2) Change the entered median to the post-modality and output the
correct formula.
(3) If the median formula is reasonable, calculate the modified
formula and output the result.
Submission:
Output through program source and input example
e.g. infix : (15+5)* (15+u5) // Actual formula is (15+5)*
(15+5)
Postfix: 15 5 + 15 5 u + *
Result value = 200
The input infix : 003.14 * 05^2 // actual formula
Postfix: 3.14 5 2 ^ *
Result value = 78.5
The input infix : (13.75 – 06.25)/u2 // The actual formula is
(13.75 – 6.25)/(-2)
Postfix: 13.75 6.25 - 2 u /
Result value = -3.75
Entered infix : (13.2 – 3.2)/2* (5.6 + u2.6) + 3)
Output: This formula cannot be calculated.
Entered infix : 2* 5.6 – 3.14*-4
Output: Unacceptable number representation. (-4)
In: Computer Science
In C++
Given a sorted list of integers, output the middle integer. A negative number indicates the end of the input (the negative number is not a part of the sorted list). Assume the number of integers is always odd.
Ex: If the input is: 2 3 4 8 11 -1
the output is:
Middle item: 4
The maximum number of inputs for any test case should not exceed 9. If exceeded, output "Too many numbers". Hint: First read the data into a vector. Then, based on the number of items, find the middle item. 276452.1593070
( Must include vector library to use vectors)
In: Computer Science
How Data transparency is provided in character-oriented protocol?
What is duplex communication channel?
In: Computer Science