Suppose there are three users: DBA, user1, user2, user3. Please specify whether user1, user2, user3 have update privilege on checking and saving table after execution of the following SQL statements.
DBA:
Grant update on checking to user1 with grant option;
Grant update on checking to user2 with grant option;
Grant update on saving to public;
Grant update on saving to user2 with grant option;
User1:
Grant update on checking to user3;
User 2:
Grant update on checking to user3;
Grant update on saving to user3;
DBA:
Revoke update on checking from user1;
Revoke update on saving from public;
In: Computer Science
Solve this question in C++ language. DO NOT use loops. Use recursive function. Keep the program simple.
Q (5) Suppose you have been given the task to design a text editor which will take any multiline text from user and then display the statistics like total number of characters i.e., characters_count (excluding the white space and punctuations), words_count, and redundant_words_count. Create a structure named Text_Editor having four type members namely inserted_text (of type string), characters_count (of type unsigned int), words_count (of type unsigned int), and redundant_words_count (of type unsigned int). The structure should also have member functions namely Insert_Text( ) for obtaining the multiline text from user and assigning to input_text member-variable. End of text insertion should be specified by ‘#’ character. Moreover, there should be a separate member-function of the created structure named Count_Ch( ), Count_Words( ), and Count_Redundant_Words( ) that should process the input text in order to calculate and print the relevant statistics. All these different tasks are to be implemented using recursion technique. (30 Points)
In: Computer Science
Below are six ciphertexts of the same message encrypted using the following four classical ciphers available in CrypTool: Caesar (shift), Substitution, Vigenere and Permutation.
Do your best to match ciphertexts with a cipher that could have been used to obtain the given ciphertext. If you are uncertain, you can list several ciphers per each ciphertext. Justify your answer. Find the plaintext, by breaking the Caesar (shift) cipher, and then find the keys for at least 3 ciphers used to encrypt the now known plaintext. All attacks must be documented. Brute-force attacks do not count.
Ciphertext 1
TFPEGO ZEKUUFJZ CZ NJNCSGZWV LWVJVH FWVL HDTD ISK QSRNYR BQJPJ
SZRPBV ML LVEIKLYVUBX WNLLQC SPJL SITU AAY EXIR TFPEGO ZEKUUFJZ
CZ NJNCSGZWR RACWHTQ HJCV CJRXSL JPIJAK NYR TG FXX CZRPBV ML
LVEIKLYVMFTIG PJCV XIPS KHQKG TS WKGWFUGKO NCQWZDTS TB TGTUAP
UBX YLRBPYSK HJCV XIPB LXQYAV WMCU NVL EFLPW VJNCSQ HB ZEKUUFJZ
CXS RVGSCGBQY HJCV AWIG UURJ AIEQ
Ciphertext 2
GSVGXK JOYOYMOJ LB NBJEOLLRO LRCTEK LRGL YGHO XBP KGHMPL TOQOJ
NBJEOL LB JOYOYMOJ LRO LRCTEK LRGL YGHO XBP ESGHGSVGXK JOYOYMOJ
LB NBJEOLLRO NJCOTHK LRGL FJBQOH PTLJPOMPL HB TBLNBJEOL LB
JOYOYMOJLRBKO LRGL RGQO KLPUA MX XBPGSVGXK JOYOYMOJ LB NBJEOL
LRO LJBPMSOK LRGL RGQO FGKKOH GVGXMPL TOQOJ NBJEOL LB JOYOYMOJ
LRO MSOKKCTEK LRGL UBYO OGUR HGX
Ciphertext 3
DOZDBVUHPHPEHU WR IRUJHWWKH WKLQJV WKDW PDGH BRX VDGEXW QHYHU
IRUJHW WR UHPHPEHUWKH WKLQJV WKDW PDGH BRX JODG DOZDBV UHPHPEHU
WR IRUJHWWKH IULHQGV WKDW SURYHG XQWUXHEXW GR QRW IRUJHW WR
UHPHPEHUWKRVH WKDW KDYH VWXFN EB BRXDOZDBV UHPHPEHU WR IRUJHW
WKH WURXEOHV WKDW KDYH SDVVHG DZDBEXW QHYHU IRUJHW WR UHPHPEHU
WKH EOHVVLQJV WKDW FRPH HDFK GDB
Ciphertext 4
AMESOV OHALEOIR EO ETUWETSAU GBSOWE THSR ETMD EGN VUGBAK YTEHS
NTRNEA RH AAFMHAAMEDE TEETBS OTAE ETTG EEG GYETTHGRFR PUFMETLB TE
PBRMSCYMR NENTRTU SOFT RTESSA MELEYOEET AL BTT UERETA MR
EOBRMHCARHTST EEIM SOTM BRMNE WE TTUOTTAYE OOHAERET CR FHAUGBGYA
RHHNNOHV OMRU AWRE BHHYTE TDOEIDL BTSDD TRHYRF RT DVOHSAEOIDT
EESOYTEAT OROE UEGB VAFM LAD
Ciphertext 5
ANWDCE ZEMGMEID BO FQRJIFBHE VHLRSA THCT PEPM YOW SDHNCT NGVHV
RWRGGT WS DMMEOBHVFPE TJIQKE BHAV MDHQ GOU ILDHMTWAAS UIYMMBGR WS
RWRGGTWLQ NRIGNGW FPAT RRRZQL UNVRXINCT DQ NRX RWRGGT WSDMMEOBHV
FPOSG TKEF PAVG SWYOS BY AOXEXEAYU RHQQUBET TR JAZGEVTKI FZOUDLHW
FPAT JAYI BISSGD DAMGBUV NHZQZ FOTGHX FW REOEPFQZTHG BOIEAINIS
WLMB COOE HEOP DAA
Ciphertext 6
VHIGCYI NKNBCNIVY DBICPKEKPIAPE FCHAPTVGVP FAYRYOHCQVE
NTNIDBICPKEKY FNKNKKFEYPIAPEF CHAPTVG VPFAYWCHVHO HZTAYS NKNKKFE
YBDYFKI KEAPNRIENFS HAPTVSEYOFPZR YEXRCQOPV FYVDBIC PKEK YFNK NKK
FEY DAPRAP TVAGTN PYRUMCTU AYWYHZTAY SNKNKKFEYB DYFKIKEAPP
KFYQCPNPY AGAPTOP TYHUPFPG ITACQVENT NIDBICPK EKYFNKNK KFEYPIMD
RPUPEFC HAPTVB YKNEPY GPSTA
In: Computer Science
Define and implement a class named Coach, which represents a special kind of person. It is to be defined by inheriting from the Person class. The Coach class has the following constructor:
Coach(string n, int sl) // creates a person with name n, whose occupation
// is “coach” and service length is sl
The class must have a private static attribute
static int nextID ;
which is the unique personID of the next Coach object to be created. This is incremented by 1 each time a new Coach object is created. This must be initialized to the value of 0 in the Coach.cpp file, the first coach has personID equal to 0.
Redefine the get_salary function inherited by Coach from Person so that it returns either the value of salary if the service length is less than 15 or three times the value of salary otherwise.
So we can check that your code compiles implement a program with a main method that declares a Coach object in a file called main-2-1.cpp.
2-2. Define and implement a class named Player, which represents a special kind of person. It is to be defined by inheriting from the Person class. The Player class has the following constructor and behaviour:
Player(string n, int sl, int *list, int m)
/* creates a person with name n, whose occupation is
“player” and service length is sl;
list records the time that a player spent in the
field in each game, the integers are distinct and
sorted in ascending order; m is the number of games
*/
int searchGame(int x)
/* searches for a particular time x in the array of times;
returns either the index of x in the array if x exists or -1 otherwise;
you may use your favourite sorting algorithm
*/
The class must have a private static attribute
static int nextID ;
which is the unique personID of the next Player object to be created. This is incremented by 1 each time a new Player object is created. This must be initialized to the value of 1000 in the Player.cpp file, the first player has personID equal to 1000.
Redefine get_salary function inherited by Player from Person so that it returns either the value of salary if service length is less than 20 or three times the value of salary otherwise.
Function searchGame should look for a particular time x in the array of times. If x exists, it returns the array index of x in the array or it returns -1 otherwise.
So we can check that your code compiles implement a program with a main method that declares a Player object in a file called main-2-2.cpp.
code:
#ifndef PERSON_H
#define PERSON_H
#include <iostream>
using namespace std;
class Person{
protected:
string name; // the name of a person
string occupation; // the occupation of a person
int salary; // the salary of a person; takes only non-negative values
int serviceLength; // the service length of a person
int personID; // the unique ID of a person
public:
Person(string n, string o, int sl);
Person();
// for name
void set_name(string input);
string get_name();
// for occupation
void set_occupation(string input);
string get_occupation();
// for salary
void set_salary(int input);
virtual int get_salary();
// for serviceLength
int get_serviceLength();
// for personID
int get_personID();
~Person();
};
#endif
#include "Person.h"
#include <iostream>
using namespace std;
Person::Person(){
}
Person::Person(string n, string o, int sl){
name = n;
occupation = o;
serviceLength = sl;
salary = 1;
}
void Person::set_name(string input){
name = input;
}
string Person::get_name(){
return name;
}
void Person::set_occupation(string input){
occupation = input;
}
string Person::get_occupation(){
return occupation;
}
void Person::set_salary(int input){
if (input >= 0){
salary = input;
}
}
int Person::get_salary()
{
return salary;
}
int Person::get_serviceLength(){
return serviceLength;
}
int Person::get_personID(){
return personID;
}
Person::~Person(){
}
In: Computer Science
The protections from the security software must continue when the device is taken off the network, such as when it is off-grid, or in airplane mode and similar. Still, much of the time, software writers can expect the device to be online and connected, not only to a local network but to the World Wide Web, as well. Web traffic, as we have seen, has its own peculiar set of security challenges. What are the challenges for an always connected, but highly personalized device?
In: Computer Science
Browse Apple apps at the iTunes App Store. Search under medical apps and attempt to organize them into categories in a table. Are there categories that are missing, e.g. clinical guidelines for patients? Any future predictions about new categories of software? Pick one of your categories and describe the types of Apps in it.
In: Computer Science
Given the below Java code snippet, assuming the code is correct, and the names are meaningful, select the best answer for the below questions:
public static void main(String[] args) {
int numStations = 10;
int enter = 0;
int exit = 0;
Train train = new Train(numStations);
for (int station = 0; station < numStations; station++)
{
enter = enter + train.enterPassengers(station);
exit = exit + train.exitPassengers(station);
}
System.out.println("Number of passengers entered the train: " + enter);
System.out.println("Number of passengers exited the train: " + exit);
System.out.println("Number of passengers remaining on the train: " + (enter-exit));
}
The for-loop in the code is:
Counting the number of stations in the train
Is looping 9 times to determine enter and exit of the train
Sums up the number of passengers entering and leaving the train
Exercise #2
Review the below Java method and assume the comments are correct.
// determines if positive number is odd or even
// returns true if even
public Boolean isEven(int num)
{
if (num <= 0)
{
return false;
}
if (num%2 = 0)
return true;
return false;
}
Select the best answer what is wrong with the code:
It is setting variable to uninitialized value
It is using undeclared variable
It is using single equal sign as equality
Exercise #3
Review the below Java method and assume the comments are correct.
// Initialize array values to 0
public void initialize()
{
int[] values = new int[10];
for (int i = 1; i <= 10; i++)
values[i] = 0;
}
Select the best answer what is wrong with the code:
It is using an uninitialized array
It is overstepping array boundary
It is looping too many times
None of the above
Exercise #4
Given the below Java code snippet, assuming the code is correct, and the names are meaningful, select the best answer for the below question:
fax.setNumber("8761234567");
fax.load(paper);
String status = fax.run();
System.out.println("The fax result status : " + status);
The code snippet :
Makes multiple paper copies
Starts the fax machine and displays status
Loads paper and sends a fax
In: Computer Science
**** In C++ ****Exercise #3: Design and implement a program (name it ArrayMethods), that defines 4 methods as follows: int arrayMax(int[] arr) returns the maximum value in the an array int arrayMin(int[] arr) returns the minimum value in an array void arraySquared(int[] arr) changes every value in the array to its square (value²) void arrayReverse(int[] arr) reverses the array (for example: array storing 7 8 9 becomes 9 8 7 ) The program main method creates a single-dimensional array of length 5 elements and initialize it with random integers between 1 and 100. The program displays the original array, then calls each of the above methods and displays their results as shown below. Document your code and organized your output following these sample runs. Sample run 1: Original array: 3, 5, 2, 6, 1 Max value: 6 Min value: 1 Squared array: 9, 25, 4, 36, 1 Reversed array: 1, 36, 4, 25, 9 Sample run 2: Original array: 3, 2, 3, 7, 2 Max value: 7 Min value: 2 Squared array: 9, 4, 9, 49, 4 Reversed array: 4, 49, 9, 4, 9 Sample run 3: Original array: 2, 2, 2, 2, 2 Maxvalue: 2 Min value: 2 Squared array: 4, 4, 4, 4, 4 Reversed array: 4, 4, 4, 4, 4
In: Computer Science
The primary objective of this assignment is to reinforce the concepts of string processing.
Part A: Even or Odd
For this first part, write a function that will generate a random number within some range (say, 1 to 50), then prompt the user to answer if the number is even or odd. The user will then input a response and a message will be printed indicated whether it was correct or not. This process should be repeated 5 times, using a new random number for each play, regardless of whether the user was correct or not.
Notes
>>> assign2PartA()
Is 41 odd or even? Odd
Correct
Is 48 odd or even? Even
Correct
Is 3 odd or even? e
Incorrect
Is 20 odd or even? o
Incorrect
Is 42 odd or even? xyz
You did not enter a correct reply.
Please answer using Odd or Even
Part B: Vowel Counting
The second task is to write a function that counts, and prints, the number of occurrences for each vowel (a, e, i, o and u) in a given phrase and outputs a (new) phrase with the vowels removed. The phrase should be accepted as a parameter to the function. If the (original) phrase is empty, you should output an appropriate error message, and obviously with no vowel counts. If the phrase contains no vowels, a message should be displayed, and the count can be omitted – since there is no point in displaying 0 for each vowel! A message should also be displayed if the phrase contains only vowels, but the counts should still be displayed.
Notes
>>> assign2PartB("Remember that context here defines
\"+\" as 'Concatenate'")
A E
I O U
4 10 1
2 0
The original phrase is: Remember that context here defines "+"
as 'Concatenate'
The phrase without vowels is: Rmmbr tht cntxt hr dfns "+" s
'Cnctnt'
>>> assign2PartB("bcdfghjklmnpqrstvwxyz")
The phrase contains no vowels: bcdfghjklmnpqrstvwxyz
>>> assign2PartB("aeiouAEIOU")
A E
I O U
2 2
2 2 2
The phrase contains only vowels: aeiouAEIOU
>>> assign2PartB("")
The input phrase is empty!
>>>
In: Computer Science
Java Class
import java.io.File;
import java.io.FileNotFoundException;
import java.util.InputMismatchException;
import java.util.Scanner;
public class ReadInData {
public static double readData(String fileName)
{
File file = new
File(fileName);
Scanner scan;
double sum = 0;
try {
scan = new
Scanner(file);
int numOfValues
= Integer.parseInt(scan.nextLine()); // Read in Val for #
values
for(int i = 0; i
< numOfValues; i++) { // for-loop to get that many values
sum += scan.nextDouble(); // add the values
together (doubles)
}
scan.close();
return sum; //
return the sum of all the values in the file
}//add catch statements
here
}
public static void main(String[] args) {
System.out.println(readData("Test3.txt"));
System.out.println(readData("Test2.txt"));
System.out.println(readData("Text4.txt")); // notice spelling of
the file name!
System.out.println(readData("Test4.txt"));
}
}
Test2.txt
6 5 3.0 "9.8" -19.8 -54.1 85.5
Test3.txt
4.0 5.0 6.2 4.2 1.0
Test4.txt
5 4.2 3.1 2.2 6.1
In: Computer Science
In: Computer Science
Find the computational complexity i.e. O(n) etc. for the following four loops and explain why you came to that answer:
In: Computer Science
I am writing a scheme function that pairs an element to every element in a list, and I have the following code so far:
(define (pair-element e l)
(cond ((null? l) (list e))
(else (cons e (car l)) (pair-element (cdr l)))))
(pair-element 4 `(4 3 5))
What is my error? I'm getting a pair element mismatch when I run it. I need to do this without using built-in functions. Thanks!
In: Computer Science
For a given CPU, the cycle latency for a set of operations are given as follows:
Addition: 4
Subtraction: 8
Multiplication: 64
Division: 80
If the clock of this CPU runs at 3GHz, find the following
How many operations of each of the list above can this CPU perform in 5 minutes?
If we have a set of operations that contains 10^9 of each operation in the list in part 1, compute the required time in seconds to execute the set. Please explain the formula used.
In: Computer Science
Please make your Task class serializable with a parameterized and copy constructor, then create a TaskListDemo with a main( ) method that creates 3 tasks and writes them to a binary file named "TaskList.dat". We will then add Java code that reads a binary file (of Task objects) into our program and displays each object to the console. More details to be provided in class.
Here is a sample transaction with the user (first time the code is run):
Previously saved Tasks from binary file:
[None, please enter new Tasks]
Please enter task name (or "quit" to exit): Ace CS 112 Final
Exam
Please enter due date (in form MM/DD/YYYY): 10/10/2019
Please enter deadline : 3:20 PM
Please enter priority : 1
After 1 Task has been saved (second time the code is run):
Previously saved Tasks from binary file:
Task [name=Ace CS 112 Midterm Exam, dueDate=10/10/2019,
deadline=3:20 PM, priority=High]
Please enter task name (or "quit" to exit): quit
I don't know how to print the priorities High, medium, and Low in the toString method to where it is stored in the binary file after the user types 1, 2, or 3. 1 for high, 2 for medium, and 3 for low.
import java.io.*;
import java.util.Scanner;
public class IC10_TaskList {
public static void main(String[] args) {
String name, dueDate, deadline;
int priority;
Scanner keyboard = new Scanner(System.in);
Task[] allTasks = new Task[10];
int count = 0;
File binaryFile = new File("Task.dat");
try {
System.out.println("\nPreviously saved tasks from the binary file:");
if (binaryFile.exists()) {
ObjectInputStream inFile = new ObjectInputStream(new FileInputStream(binaryFile));
allTasks = (Task[]) inFile.readObject();
inFile.close();
for(int i = 0; i < allTasks.length; i++){
if(allTasks[i] != null){
System.out.println(allTasks[i]);
count++;
}
else
break;
}
}
else
System.out.println("[None, Please enter new task data]");
}
catch(IOException e){
System.err.println("Cannot find Task.dat");
}
catch(ClassNotFoundException e){
System.err.println("Serial Task version does not match.");
}
do{
System.out.print("\nPlease enter task name(or \"quit\" to exit): ");
name = keyboard.nextLine();
if(name.equalsIgnoreCase("quit"))
break;
System.out.print("Please enter due date(in form MM/DD/YYYY): ");
dueDate = keyboard.nextLine();
System.out.print("Please enter deadline: ");
deadline = keyboard.nextLine();
System.out.print("Please enter priority: ");
priority = keyboard.nextInt();
allTasks[count++] = new Task(deadline, dueDate, name, priority);
keyboard.nextLine();
} while(!name.equalsIgnoreCase("quit"));
try{
ObjectOutputStream outFile = new ObjectOutputStream(new FileOutputStream(binaryFile));
outFile.writeObject(allTasks);
outFile.close();
}
catch(IOException e){
System.err.println("File Task.dat cannot be found and/or written.");
}
}
}
import java.io.Serializable;
import java.util.Objects;
public class Task implements Serializable {
public static final long serialVersionUID = 1;
private String mDeadline;
private String mDueDate;
private String mName;
private int mPriority, mChoice;
public Task(String deadline, String dueDate, String name, int priority) {
mDeadline = deadline;
mDueDate = dueDate;
mName = name;
mPriority = priority;
}
public String getDeadline() {
return mDeadline;
}
public void setDeadline(String deadline) {
mDeadline = deadline;
}
public String getDueDate() {
return mDueDate;
}
public void setDueDate(String dueDate) {
mDueDate = dueDate;
}
public String getName() {
return mName;
}
public void setName(String name) {
mName = name;
}
public int getPriority() {
return mPriority;
}
public void setPriority(int priority) {
mPriority = priority;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Task task = (Task) o;
return mPriority == task.mPriority &&
mDeadline.equals(task.mDeadline) &&
mDueDate.equals(task.mDueDate) &&
mName.equals(task.mName);
}
@Override
public int hashCode() {
return Objects.hash(mDeadline, mDueDate, mName, mPriority);
}
@Override
public String toString() {
return "Task[" +
"Name = " + mName +
", Due Date = " + mDueDate +
", Deadline = " + mDeadline +
", Priority = " + mPriority +
"]";
}
}In: Computer Science