1. A company that wants to send data over the Internet will use an encryption program to ensure data security. All data will be transmitted as four-digit integers. The application should read a four-digit integer entered by the user and encrypt it as follows: Replace each digit with the remainder of the new value divided by 10 by adding 6 to the digit. Then replace the number in the first digit with the third, and the number in the second digit with the fourth. Print the encrypted integer on the screen. Write a separate application where an encrypted four-digit integer is entered and decrypted (reversing the encryption scheme) and finds the original number.
2. Create a class called Employee that contains three instance variables (First Name (String), Last Name (String), Monthly Salary (double)). Create a constructor that initializes these variables. Define set and get methods for each variable. If the monthly salary is not positive, do not set the salary. Create a separate test class called EmployeeTest that will use the Employee class. By running this class, create two employees (Employee object) and print the annual salary of each employee (object). Then set the new salary by giving each employee a 10% raise and display each employee's annual salary on the screen again.
Note: code should be written in Java language.
In: Computer Science
Q.3 Consider the function f(x) = x^2– 2x + 4 on the interval [-2, 2] with h = 0.25. Write the MATLAB function file to find the first derivatives in the entire interval by all three methods i.e., forward, backward, and centered finite difference approximations.
In: Computer Science
Discuss the Minimum System Requirements for Windows
In: Computer Science
Using Ubuntu SeedLab
For block ciphers, when the size of a plaintext is not a multiple of the block size, padding may be required. All the block ciphers normally use PKCS#5 padding, which is known as standard block padding. We will conduct the following experiments to understand how this type of padding works:
1. Use ECB, CBC, CFB, and OFB modes to encrypt a file (you can pick any cipher). Please report which modes have paddings and which ones do not. For those that do not need paddings, please explain why.
2. Let us create three files, which contain 5 bytes, 10 bytes, and 16 bytes, respectively. We can use the following "echo -n" command to create such files. The following example creates a file f1.txt with length 5 (without the -n option, the length will be 6, because a newline character will be added by echo): $ echo -n "12345" > f1.txt
We then use "openssl enc -aes-128-cbc -e" to encrypt these three files using 128-bit AES with CBC mode. Please describe the size of the encrypted files.
We would like to see what is added to the padding during the encryption. To achieve this goal, we will decrypt these files using "openssl enc -aes-128-cbc -d". Unfortunately, decryption by default will automatically remove the padding, making it impossible for us to see the padding. However, the command does have an option called "-nopad", which disables the padding, i.e., during the decryption, the command will not remove the padded data. Therefore, by looking at the decrypted data, we can see what data are used in the padding. Please use this technique to figure out what paddings are added to the three files.
It should be noted that padding data may not be printable, so you need to use a hex tool to display the content. The following example shows how to display a file in the hex format:
$ hexdump -C p1.txt 00000000 31 32 33 34 35 36 37 38 39 49 4a 4b 4c 0a |123456789IJKL.
$ xxd p1.txt 00000000: 3132 3334 3536 3738 3949 4a4b 4c0a
123456789IJKL.
In: Computer Science
(C++)Heapsort: Write C++ codes for heapsort. The input array is a random permutation of A={1,
2, 3, …, 99, 100}. You should write codes to generate and print the random permutation first.
In: Computer Science
Python3 Please add comments
Write a program that implements the word guessing game
- There is a secret word
- The user enters letters one at a time, if the letter appears in the secret word, it is revealed. Otherwise, it counts as a wrong guess.
If the user reveals all the letters in the word before getting too many wrong guesses then they win!
Otherwise, they lose.
1 - define secret word
2 - create a revealed letter list that starts empty
2. set wrong guess count to 0
3. ask the user for a letter
4. is the letter in the secret word?
5. if so: add it to the revealed letters list
create a blank string
for each letter in the secret word, if the letter in
revealed letter list, add that letter to string,
otherwise add an underscore to string
6. if letter not in secret word, add one to wrong guess
7. repeat from step 3
In: Computer Science
Hello, I need to convert this java array into an array list as I am having trouble please.
import java.util.Random;
import java.util.Scanner;
public class TestCode {
public static void main(String[] args) {
String choice = "Yes";
Random random = new Random();
Scanner scanner = new Scanner(System.in);
int[] data = new int[1000];
int count = 0;
while (!choice.equals("No")) {
int randomInt = 2 * (random.nextInt(5) + 1);
System.out.println(randomInt);
data[count++] = randomInt;
System.out.print("Want another random number (Yes / No)? ");
choice = scanner.next();
}
int min = data[0], max = data[0];
for (int i = 0; i < count; i++) {
if (data[i] > max) max = data[i];
if (data[i] < min) min = data[i];
}
System.out.println("Percentage of Yes values is " + (((count-1)*100.0)/count));
System.out.println("Maximum value is " + max);
System.out.println("Minimum value is " + min);
}
}In: Computer Science
C
Implement the function Append (char** s1, char** s2) that appends the second character array to the first, replaces the first array with the result and replaces the second character array with the original first array. For example, if the first character array is "hello" and the second is "world" at the end of the function the new value of the first character array should be"helloworld" and the second array should be "hello". If the input is invalid the function should return 1. Otherwise, the function should return 0.
Input is double pointer (**). No use of <string.h>, USE malloc
#include <stdlib.h>
#include <stdio.h>
int
Append(char **s1, char **s2){
//implement
}
int main(){
char myArray1[7] = "hello";
char myArray2[10] = "world";
char *myArray3 = myArray1;
char *myArray4 = myArray2;
Append(&myArray3, &myArray4);
return 0;
}
In: Computer Science
C++ needed
Create a loop which gives the player instructions on what to input. Then read input from the player. The input will be either one of three options:
• If the user enters the word “answer” or some other string you choose to indicate the player is ready to end the game and guess. In this case, output the hidden rule.
• Three numbers separated by spaces. Let’s call a trio of numbers and the corresponding output a Guess. Once a user makes a Guess. If the user enters a sequence that follows the rules, output “Yes!” Otherwise output “No.”
• Treat any other entry as an exception.
In: Computer Science
Design the logic in pseudocode for Bugz App software company
that sells a software package
as follows.
1. The retail price of the package is $99
2. Quantity discounts are given on purchases of 10 or more units as
follows The program
must allow the user to enter the customer’s name and number of
units purchased, and
output the original cost of the units purchased, the percentage
discount given, the dollar
amount of the discount given, and the final cost after
discount.
1. If the customer purchases up to 19 units, they receive a
discount of 20%
2. 20 to 49 units – discount of 30%
3. 50 to 99 units – discount of 40%
4. 100 or more units – discount of 50%
In: Computer Science
C++ please
Instructions
Download and modify the Lab5.cpp program.
Currently the program will read the contents of a file and display each line in the file to the screen. It will also display the line number followed by a colon. You will need to change the program so that it only display 24 lines from the file and waits for the user to press the enter key to continue.
Do not use the system(“pause”) statement.
Download Source Lab 5 File:
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
ifstream file; // File stream object
string name; // To hold the file name
string inputLine; // To hold a line of input
int lines = 0; // Line counter
int lineNum = 1; // Line number to display
// Get the file name.
cout << "Enter the file name: ";
getline(cin, name);
// Open the file.
file.open(name);
// Test for errors.
if (!file)
{
// There was an error so display an error
// message and end the program.
cout << "Error opening " << name << endl;
}
else
{
// Read the contents of the file and display
// each line with a line number.
while (!file.eof())
{
// Get a line from the file.
getline(file, inputLine, '\n');
// Display the line.
cout << setw(3) << right << lineNum
<< ":" << inputLine << endl;
// Update the line display counter for the
// next line.
lineNum++;
// Update the total line counter.
lines++;
}
// Close the file.
file.close();
}
return 0;
}
In: Computer Science
HTML 5
(Website Registration Form with Optional Survey) Create a website registration form to obtain a user’s first name, last name and e-mail address. In addition, include an optional survey question that asks the user’s year in college (e.g., Freshman). Place the optional survey question in a details element that the user can expand to see the question.
In: Computer Science
Describe some design trade-offs between efficiency and safety in some language you know.
In: Computer Science
Write a Java program that uses printf, and takes user input to find the name of the File.
Write a program that compares to files line by line, and counts the number of lines that are different. You can use file1.txt and file2.txt when testing your program, but you must ask for the file names in the input.
main
Interactively requests the names of the two files, after creating the Scanner for the keyboard.
Creates a Scanner for each of the two files.
Calls countDifferentLines with references to the two Scanners as parameters and accepts an integer return value.
Prints the result (see sample).
countDifferentLines
Accepts references to the two Scanners as parameters
Compares the two files line by line – They may have a different number of lines
Return the number of lines that are different
Sample output
Please enter name of the first file to compare: file1.txt
Please enter name of the second file to compare: file2.txt
The files differ in 4 line(s)
In: Computer Science
HTML 5
(Creating an Autocomplete Form with a datalist) Create an autocomplete input element with an associated datalist that contains the days of the week.
In: Computer Science