In: Computer Science
Write a short program that asks the user for a sentence and prints the result of removing all of the spaces. Do NOT use a built-in method to remove the spaces. You should programmatically loop through the sentence (one letter at a time) to remove the spaces.
In: Computer Science
Implement a Factory Design Pattern for the code below:
MAIN:
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class Main {
public static void main(String[] args) {
Character char1 = new Orc("Grumlin");
Character char2 = new Elf("Therae");
int damageDealt = char1.attackEnemy();
System.out.println(char1.name + " has attacked an enemy " +
"and dealt " + damageDealt + " damage");
char1.hasCastSpellSkill = true;
damageDealt = char1.attackEnemy();
System.out.println(char1.name + " has attacked an enemy " +
"and dealt " + damageDealt + " damage");
int damageTaken = char2.takeHit();
System.out.println(char2.name + " has taken a hit and " +
"been dealt " + damageTaken + " damage");
char2.hasDodgeAttackSkill = true;
damageTaken = char2.takeHit();
System.out.println(char2.name + " has taken a hit and " +
"been dealt " + damageTaken + " damage");
}
}
CHARACTER:
import java.util.Random;
public abstract class Character {
protected String name;
protected int strength;
protected int resilience;
protected boolean hasCastSpellSkill;
protected boolean hasDodgeAttackSkill;
public int attackEnemy() {
Random random = new Random();
int damageDealt;
if (hasCastSpellSkill) {
int spellDamage = random.nextInt(5);
damageDealt = this.strength + spellDamage;
} else {
damageDealt = strength;
}
return damageDealt;
}
public int takeHit() {
Random random = new Random();
int damageDealt = random.nextInt(15);
int damageTaken;
if (hasDodgeAttackSkill) {
double chanceToDodge = random.nextDouble();
if (chanceToDodge > 0.50) {
damageTaken = 0;
} else {
damageTaken = damageDealt - resilience;
}
} else {
damageTaken = damageDealt - resilience;
}
if (damageTaken < 0) {
damageTaken = 0;
}
return damageTaken;
}
}
ELF:
public class Elf extends Character {
public Elf(String name) {
this.name = name;
this.strength = 4;
this.resilience = 2;
}
}
ORC:
public class Orc extends Character {
public Orc(String name) {
this.name = name;
this.strength = 10;
this.resilience = 9;
}
}
In: Computer Science
Write three functions that compute the square root of an argument x using three different methods. The methods are increasingly sophisticated, and increasingly efficient. The square root of a real number x is the value s such that s*s == x. For us, the values will be double precision variables and so may not be perfectly accurate. Also, for us, assume that x is in the range 0.0 to 100.0. You program should have a main() that asks the user for x and an accuracy bound, and then prints out the approximate square root for each of the three methods. If x is negative write an error message and exit. One. Write a pure function double sqrtLS(x, accuracy) that computes the square root of x using Linear Search. Do this in a loop that starts s at 0.0 and bestError at x. Each iteration of the loop computes error = |x-s*s|. If error< bestError, set bestError to error, and bestS to the current s. Then increment s by accuracy and move on. At the end of the loop, return bestS. This method is linear search, it searches along the number line for the best s that is within accuracy of the true value. Use the function double fabs(double) from the math library to compute absolute value. Two. Write a pure function double sqrtBS(x,accuracy) that computes the square root of x using Binary Search. (This method is also called bisection.) Start a variable low at 0.0 and a variable high at 10.0. This assumes that x will be no larger than 100.0 In a while loop do this: Compute the midpoint mid=(low+high)/2. If |x-mid*mid| ≤ accuracy return mid. If mid*mid < x set low = mid. Else set high = mid. Three. Write a pure function double sqrtNM(x, accuracy) that computes the square root of x using Newton’s Method. Recall the method: Start out an initial guess s=1.0 (or any value). Now repeatedly improve the guess: s = (s + x/s)/2 When the guess meets the ending condition |x-s*s| is ≤ bound return s. M:\ClassApps>gcc -lm squareRoot.c M:\ClassApps>.\a Enter x --> 47.5 Enter error bound --> 1e-5 sqrtLS(47.500)= 6.892020; s*s = 47.499940 sqrtBS(47.500)= 6.892024; s*s = 47.499999 sqrtNM(47.500)= 6.892024; s*s = 47.500001 Use ANSI-C syntax. Do not mix tabs and spaces. Do not use break or continue.
In: Computer Science
NETWORK SYSTEM MANAGEMENT.
Given the following attributes in a project management:
Project scope & feasibility
Documentation
Project planning
Testing and piloting
Risk minimisation
Discuss briefly each of them and on how would you use them as the IT manager for the company. Provide a details information support your discussion.
Remarks:
Total 50 Marks for this questions.
In: Computer Science
Discuss FTP(File Transfer Protocol), including all relevant terms in your explanation.
In: Computer Science
Reference: Case Study 5
1. def scramble2Encrypt(plainText ):
2 evenChars = ""
3 oddChars = ""
4 charCount = 0
5 for ch in plainText :
6 if charCount % 2== 0:
7 evenChars =
evenChars + ch
8 else:
9 oddChars
= oddChars + ch
10 charCount = charCount + 1
11 cipherText = oddChars + evenChars
12 return cipherText
22. (10 points) Refer to the code in Case Study 5. Provide a
line-by-line description of what is happening on lines 5 through
10. What are those lines of code actually doing? Please don’t
merely translate the code to words. I know that in line 7, we are
adding ch to evenChars, but what does that mean? =)
In: Computer Science
Table Name: CUSTOMERS_1
CUST_NUM CUST_LNAME CUST_FNAME CUST_BAL
2001 James William $2,999
2002 Crane Frasier $983
Table Name: CUSTOMERS_2
CUST_NUM
CUST_LNAME CUST_FNAME CUST_BAL
1999 Anderson Anne $510
2000 Bryant Juan $21
2002 Crane Frasier $983
2003 Dent George $1,790
Table Name: CUST_INVOICES
INV_NUM CUST_NUM INV_DATE INV_AMOUNT
9000 2000 23-Mar-16 245
9001 2001 23-Mar-16 260
9002 2001 30-Mar-16 275
9003 1000 10-Apr-16 286
using this information, i need help formulating an sql query:
Write a SQL code that will show CUST_NUM, CUST_LNAME, and CUST_FNAME for the one who has minimal INV_AMOUNT
In: Computer Science
Create a table with two columns. Name the table First Initial _ Last Name (e.g. John Dow will create table j_dow). You have to audit all DML statements on your table. To do this you write two triggers: 1. To log any DML statements that users might run on this table. The results must be stored in the First Initial _ Last Name _ Log table (e.g. John Dow will create table j_dow_log). The table should have unique event ID, values for both the Oracle and the system user who ran the query, the time it was executed and the type of DML query user ran. 2. To capture any data that was changed in the table. The results must be stored in the First Initial _ Last Name _ History table (e.g. John Dow will create table j_dow_history). The table should reference the event ID from the log table, and store both old and new values for both columns.
In: Computer Science
In: Computer Science
What are the advantages and disadvantages of using Trusted Platform Module (TPM)?
What are the advantages and disadvantages of using thin clients?
In: Computer Science
write a c++ program using micro soft visual studio 2010 to write a program and store 36 in variable x and 8 in variable y. add them and store the result in the variable sum. then display the sum on screen with descriptive text. calculate the square root of integer 36 in x. store the result in a variable. calculate the cube root of integer 8 in y. store result in a variable. display the results of square root and cube root on the screen.
In: Computer Science
In: Computer Science
Software hacking is a global problem that often impacts organizations that hold extensive or sensitive data on customers, employees, or others. Research an example of a company, governmental agency, or organization that has been victimized by hackers.Answer the following questions:
In: Computer Science
Write a program to take input of scores for Chemistry, Biology and English for a student and display the average with 2 decimal places if all of the three scores are in the range between 1 and 100 inclusive. Program should also display the course name for which scores are entered out of range telling Average couldn't be calculated.
Following is a sample run:
Enter scores for
Chemistry, Biology and English between 1 and 100:
45
89
96
Avg score is 76.67
Following is another sample run:
Enter scores for
Chemistry, Biology and English between 1 and 100:
900
78
89
Average cannot be calculated because Chemistry Scores were not in
range.
Following is another sample run:
Enter scores for
Chemistry, Biology and English between 1 and 100:
89
767
8787
Average cannot be calculated because Biology Scores were not in
range.
Average cannot be calculated because English Scores were not in
range.
Following is another sample run:
Enter scores for
Chemistry, Biology and English between 1 and 100:
87
90
-1
Average cannot be calculated because English Scores were not in
range.
In: Computer Science