Using C++, identify suitable coding modules for the following
(a) Overload the * operator so that two instances of Quat can be
multiplied using the * operator.
Given that q1 and q2 are Quaternions. Let q1 = (a1, b1i, c1j, d1k)
and q2 = (a2, b2i, c2j, d2k)
The product (q1 * q2) is ( a1a2 – b1b2 – c1c2 – d1d2, (a1b2 + b1a2
+ c1d2 – d1c2)i, (a1c2 + c1a2 + d1b2 – b1d2)j, (a1d2 + d1a2 + b1c2
– c1b2)k )
For example
sq1 = (5, 2i, 6j, 8k)
sq2 = (3, 5i, 7j, 6k)
sq3 = sq1 * sq2 = (-85, 11i, 81j, 38k)
(b) Overload the == operator so that we can check whether two
instances of Quat are equal. Two instances are equal if each
element in one instance is equal to the corresponding element in
the other instance.
In: Computer Science
You have 10 shirts, 9 pants, and 4 belts. How many outfits can you make out of these? (Assume all colors are perfectly coordinated.)
In: Computer Science
What are some of the basic precautions a computer owner or network administrator can take to help make the computing environment secure?
What are some of the basic security threats that a user or administrator might have to face?
In: Computer Science
In the system development life cycle (SDLC), why does the planning phase exists and what does it contribute to the development of a system?
In: Computer Science
In the system development life cycle (SDLC), why does the design phase exists and what does it contribute to the development of a system?
In: Computer Science
Unix treats file directories in the same fashion as files; that is, both is defined by the same type of data structure, call an inode. As with files, directories include a non-bit protection string. If care is not taken, this can create access control problems. For example, consider a file with protection mode 644 (rw- r-- r--) contained in a directory with protection mode 730 (rwx -wx ---). Write a small report (~250 words) how might the file be compromised in this case?
In: Computer Science
Program #3
● Filename: pig.py
For this assignment, you’ll implement a dice game called PIG, pitting two human players against each other. PIG is played with a standard six-sided die and proceeds as follows:
● Each player starts with zero points, and the first to 20 points wins.
● The current player chooses to roll or hold.
● If they choose roll:
○ The six-sided die is rolled
○ The value of the die is added to their round points.
○ The player goes again UNLESS...
○ ...If the value on the die is 1, then the round is over and the player has lost all the points they
accumulated in the round.
● If they choose hold:
○ The points accumulated in the round are added to the player’s overall score.
○ The round is over.
● When the round ends (either because the player rolled a 1 or they chose to hold), it becomes the other
player’s turn unless somebody has won.
● We check to see if someone won at the end of each round (which is kind of unfair, because if Player
One gets 20 points on the first round, then Player Two never gets a chance, but oh well tough for them).
Requirements:
● Prompt each player to either R (roll) or H (hold).
● If they enter anything else, continue prompting them until they enter a correct input.
● On a roll, randomly generate a value 1-6 to represent the die.
● End the round when the die roll is value 1 (round points are lost), or the player chooses Hold (round
points are added to that player’s overall score).
● End the game one either player has 20 or more points and announce the winner.
● Report everything as you go along -- what the die roll was, number of points so far, etc.
● As always with your CS5001 programs, your input/output must be friendly and informative.
Helpful hints
Python has a random module that can help you generate random numbers. You probably want to import random for this part of the assignment and call randint(...)
import random # near the top of your file random.randint(1, 6) # or something like this in your program
AMAZING points:
● Allow them to enter upper or lowercase letters. R/r for roll, and H/h for hold.
● Make your code extensible enough that we could add an arbitrary number of players with minimal
coding-pain. (Consider using a list to store the player names and another list for the number of points each player has.)
In: Computer Science
I want to compare between breaking the shift (Caesar Cipher), substitution, and Vigenere cipher by using a chosen-plaintext attack or by known-plaintext attack. How much plaintext must be encrypted in order for the adversary to completely recover the key for those ciphers in chosen-plaintext attack and in known-plaintext attack? is there difference in each attack?
In: Computer Science
Create a c++ program to compute the product of two integers. call create the following functions:
1. getNum - to accept only positive numbers && will call computeProd.
2.computeProd - to compute the product of the numbers & will call the function displayProduct.
3. displayProduct - to display the product.
Call the function getNum in the main function.
Compute the product w/o using the multiplication operator(*).
using #include <iostream> only
In: Computer Science
Python Please
An n-sided regular polygon has all its sides of the same length and all its angles of the same degree. It is also called an equilateral and equiangular polygon. In this activity, you will design a class named RegularPolygon that contains:
Write a main function to test the RegularPolygon class.
In: Computer Science
In Angel, you will find a class called Employee. This class should include a constructor which sets name to blanks and salary to $0.00 and a constructor which sets name to a starting name and salary to a set amount. Additionally, the class should include methods to set the name and salary and return the name and salary. Create another method to return the name and salary nicely formatted as a string (hint – research the toString method).
You will create a new class called Manager that inherits from the class Employee. Add a field named department of type String. Supply a method toStringthat prints the manager's name, department, and salary. Remember, you may not change anything in the Employee class.
You will then create a test class that uses the Manager class. The test class should prompt the user to enter name, department and salary. This information should be stored in an array. Upon entry of 3 employee records, the program should output the information you entered.
Your program should be able to handle a maximum of 3 entries.
You may write the program as a console application or using dialog boxes.
please write a code using java. Make sure the code is correct for java eclipse.
In: Computer Science
C++ Language
Create Login Register program without open .txt
file
simple program also if you can hide password input
option menu
1) Login
2) Register
3) exit
In: Computer Science
b) With the aid of examples, discuss the various issues that could indicate that a Disaster Recovery Plan is not in order. [25 marks].
In: Computer Science
Topic: Computer Science | Java Programming
Complete the class Packet below. The Packet class contains: Four private instance variables to store information regarding to the source host, destination host, time stamp and ip packet size. A constructor that takes a string object as a parameter and set up instance variables defined above. public accessor methods: getSourceHost(), getDestinationHost(), getTimeStamp(), and getIpPacketSize(); public mutator methods: setSourceHost(), setDestinationHost(), setTimeStamp(), and setIpPacketSize(); A toString() method that returns a string description of a packet.
Test case1: Packet p1 = new Packet("1\t0.000000000\t192.168.0.24\t\t10.0.0.5\t\t98\t84\t\t\t\t\t\t\t\t1"); System.out.println(p1);
Excepted output src=192.168.0.24, dest=10.0.0.5, time=0.00, size=84
Test case2: Packet p2 = new Packet("6\t5.000675000\t\t\t\t\t60\t\t\t\t\t\t\t\t\t"); System.out.println(p2);
Excepted output src=, dest=, time=5.00, size=0
Test case3:
Packet p3 = new Packet("36\t33.434837000\t192.168.0.15\t8000\t10.0.0.5\t47745\t74\t60\t0\t1\t1\t0\t0\t0\t1\t1"); System.out.println(p3);
Excepted output: src=192.168.0.15, dest=10.0.0.5, time=33.43, size=60
In: Computer Science
Please answer the following questions:
Consider the IMU unit which has 9 degrees of freedom.
Thank you :)
In: Computer Science