Hacktivism is the use of hacking to promote a political cause. Is there an ethical justification for such hacking?
Should penalties for 'hacktivists' differ from penalties for other hackers?
In: Computer Science
Seminar on Oct 5: Operating Systems
1. List one or more
A. Stand-alone operating system
B. Network operating system
C. Embedded operating system
D. Possible applications of embedded system
E. Open-source operating system
F. Single-tasking operating system
G. Operating system based on Unix/Linux
H. Multitasking operating system
I. Multithreading operating system
J. Mobile-device operating system
2. What is:
(a) boot sector
(b) bootstrap loader
(c) partition
In: Computer Science
What are the additional elements required of a network architecture if the enclave is to support remote access through the public Internet?
True or false: A thin client is a PC or laptop without a hard drive or storage space.
What are the five elements of a Remote Access Security Readiness Review
In: Computer Science
Program 5A: Determine which student has the highest grade Write a Java program that determines which student has the highest grade. You will ask the user to enter the number of students. Then you will ask for each student and their grade. You will output the name and grade of the student with the highest grade. You will NOT use an array for this assignment.
Call your class Program5A, so your filename will be Program5A.java. It is essential for grading purposes that everyone have the same class name. 2. Create several lines of comments of identification and description at the top of the file (it doesn’t have to look exactly like this, in particular, if your editor wants to put * in front of every line, that’s fine):
Use comments liberally to document exactly what you are doing in the program. 4. Use descriptive variable names in camel-case with the first letter in lowercase. 5. Ask the user for the number of students and assign that to a variable of type int called numStudents using the nextInt method of Scanner.
At this point, try to compile and run your program. Don’t move on until this part is working. It would be good to enter a temporary print statement just to make sure this is working: System.out.printf("numStudents = %d\n", numStudents); It should be commented out before turning in the program (put // in front of it) or delete the line.
We need variables for highestName and highestScore of types String and int, respectively. Set highestName to the empty string and highestScore to 0.
Create a for loop. (Do NOT put a semi-colon after the for statement. Put an open curly brace instead, and go ahead and put the closing brace if your IDE doesn’t do it automatically, then put all the statement to be repeated BETWEEN the curly braces):
for (int i = 0; i < numStudents; i++) { a. As the first statement in the loop, add an extra line that reads to the end of the line: input.nextLine(); This is needed after a nextInt if you are going to then read a String. This basically burns the rest of the line (it ignores everything else to and including the end of the line which in this case will just be an end-of-line character '\n'), even though there is nothing there that you can see. You will need to do this any time that you have read in an int as you did for the number of students. (You could have done it right after you read the number of students, but then you would have to do it again in the loop right after reading the score. Doing it here takes care of both with one line of code.) b. Ask the user for name and score, which will be String and int types, respectively, which will require nextLine and nextInt. c. Compare score to highestScore. If score is greater than highestScore, then assign highestScore equal to score and highestName equal to name. There will not be an else. (If they are equal, we are NOT going to change the highest score so that in the event of a tie, the first one wins. However, in real life we would deal with ties in a better manner.) d. This is the end of the for loop, so put the closing brace if it’s not already there.
Outside of the for loop, print highestName and highestScore
ample Runs: (Enter this data exactly and make screen-prints to paste into a Word document that you will turn in to prove that your program works correctly. On the last one, just hit the Enter key without entering anything; it should sit there still waiting for integer input; if you then enter an integer, everything is fine and works like normal.):
Please enter number of students:4
Enter student name:Gus
Enter score:70
Enter student name:Suzy
Enter score:80
Enter student name:Allie
Enter score:100
Enter student name:Robert
Enter score:90
Highest score: Allie 100
Process finished with exit code 0
In: Computer Science
Given an int b, set the variable answer to equal "negative" if b is less than 0; set answer to "positive" if b is greater than 0; and set it to "zero" if b equals zero
in python
In: Computer Science
1.What are the two fundamental models of inter-process communication? What are the two system calls used with message-passing systems?
2.How do processes communicate? What are blocking and non-blocking communication primitives?
3.Explain Remote Procedure Calls with the help of diagram.
4.Are function callback and inter-process communication same?
In: Computer Science
JAVA
/**
* posOfLargestElementLtOeT returns the position of the
largest element in the
* array that is less than or equal to the limit
parameter if all values are
* greater than limit, return -1;
*
* Precondition: the array is nonempty and all elements
are unique. Your
* solution must go through the array exactly
once.
*
* <pre>
* 0 == posOfLargestElementLtOeT(3, new double[] { -7
}) // value:-7 is in pos 0
* 5 == posOfLargestElementLtOeT(3, new double[] { 11,
-4, -7, 7, 8, 1 }), // value:1 is in pos 5
* -1 == posOfLargestElementLtOeT(-7, new double[] { 1,
-4, -5, 7, 8, 11 }), // all elements are > -7
*
* The code below is a stub version, you should replace
the line of code
* labeled TODO with code that achieves the above
specification
* </pre>
*/
public static int posOfLargestElementLtOeT(double
limit, double[] list) {
return -2; // TODO 2: fix this
code
}
In: Computer Science
JAVA SHOW YOUR OUTPUT
package exampletodo;
import java.util.Arrays;
import stdlib.*;
/**
* Edit the sections marked TODO
*
* Unless specified otherwise, you must not change the declaration of any
* method.
*/
public class example {
/**
* valRange returns the difference between the maximum and minimum values in the
* array; Max-Min. Precondition: the array is nonempty. Your solution must go
* through the array at most once.
*
* Here are some examples (using "==" informally):
*
* <pre>
* 0 == valRange (new double[] { -7 })
* 10 == valRange (new double[] { 1, 7, 8, 11 })
* 10 == valRange (new double[] { 11, 7, 8, 1 })
* 18 == valRange (new double[] { 1, -4, -7, 7, 8, 11 })
* 24 == valRange (new double[] { -13, -4, -7, 7, 8, 11 })
*
* The code below is a stub version, you should replace the line of code
* labeled TODO with code that achieves the above specification
* </pre>
*/
public static double valRange(double[] list) {
return -1; // TODO 1: fix this code
}
/**
* posOfLargestElementLtOeT returns the position of the largest element in the
* array that is less than or equal to the limit parameter if all values are
* greater than limit, return -1;
*
* Precondition: the array is nonempty and all elements are unique. Your
* solution must go through the array exactly once.
*
* <pre>
* 0 == posOfLargestElementLtOeT(3, new double[] { -7 }) // value:-7 is in pos 0
* 5 == posOfLargestElementLtOeT(3, new double[] { 11, -4, -7, 7, 8, 1 }), // value:1 is in pos 5
* -1 == posOfLargestElementLtOeT(-7, new double[] { 1, -4, -5, 7, 8, 11 }), // all elements are > -7
*
* The code below is a stub version, you should replace the line of code
* labeled TODO with code that achieves the above specification
* </pre>
*/
public static int posOfLargestElementLtOeT(double limit, double[] list) {
return -2; // TODO 2: fix this code
}
/**
* isPerfectNumber determines (true or false) if a given number is a 'Perfect
* Number'
*
* A perfect number is one that is equal to the sum of its proper divisors.
* Example 1: 6; the proper divisors are 1, 2, 3 ; 1+ 2 + 3 is 6, so 6 IS a
* perfect number Example 2: 15; the proper divisors are 1, 3, 5 ; 1 + 3 + 5 is
* 9, so 15 IS NOT a perfect number Example 3: 28; the proper divisors are 1, 2,
* 4, 7, 14; 1 + 2 + 4 + 7 + 14 is 28, so 28 IS a perfect number
*
* Precondition: number is a positive integer
*
* The code below is a stub version, you should replace the line of code labeled
* TODO with code that achieves the above specification
*
* Hint: find the sum of the proper divisors
*/
public static boolean isPerfectNumber(int number) {
return false; // TODO 3: fix this code
}
In: Computer Science
Design the Python GUI to display the temperature & humidity on two gauges.
- Use the Tkinter Canvas Widget.
- The gauge should be in a separate file and can be integrated using the import directive.
- The gauge should have at least two parameters; e.g. the range (scale: min-max) and the fill color of the moving arc. You are free to add more.
You have to design the gauge and not import it
****PYTHON code*****
In: Computer Science
Your HTML document should contain the following elements/features:
In: Computer Science
Having trouble with the Luhn algorithm for java. Everything works great except for when cthe number 5105105105105109 is entered. I'm sure there are other numbers that do this, but this returns check digit as 10 when it should come back as 0. Suggestions? here is the algorithm and then my current code without the prints because my error is in the math. I am not allowed to use break.
Another key part of the credit card number standard is the check digit. The last digit of every credit card number is determined by the previous 15 digits through a simple mathematical formula known the Luhn Algorithm. The Lhun Algorithm can be used to check if a credit card number has been corrupted in its transmission between the vendor reading the card, and the bank which has the account. It can also be used to check to see if a credit card number is valid before transmitting it to the bank.
The Luhn Algorithm is described at the link above, but the basic idea is:
For example, suppose the card you want to validate is: 5457623898234113. In this case the check-digit is 3 and the remaining digits are the 15-digit account number. We can confirm that we likely have a good card number by validating the check digit as follows:
| Position | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
| Original Value | 5 | 4 | 5 | 7 | 6 | 2 | 3 | 8 | 9 | 8 | 2 | 3 | 4 | 1 | 1 | 3 |
| Doubled value | 10 | 10 | 12 | 6 | 18 | 4 | 8 | 2 | ||||||||
| Doubled-value adjusted | 1 | 1 | 3 | 6 | 9 | 4 | 8 | 2 | ||||||||
| Sum of values = 67 | 1 | 4 | 1 | 7 | 3 | 2 | 6 | 8 | 9 | 8 | 4 | 3 | 8 | 1 | 2 | |
| Check digit is 3 (10 - 7 = 3) |
You can read more about credit card numbers, as well as how the Luhn Algorithm is used in other areas of Computer Science, in this article from the Data Genetics blog (where the above example was taken from).
For this lab you will write a Java program that checks credit card strings to see if they are valid. Your program should first prompt the user to enter a string of numbers as a credit card number, or enter a blank line to quit the program. If the user doesn't quit, your program should ensure that this string is exactly 16 characters in length. If the user enters a string that is not 16 characters in length, your program should print an error message and ask again for a valid string. Your program should use the Luhn Algorithm above to compute what the check digit should be and then compare it to the actual value in the provided string and report whether the credit card number is valid or wrong. If it is wrong, your program should report what the correct check digit should be for the input value. Your program should keep asking for new values until the user enters a blank line to quit the program.
Create a new project named LuhnAlgorithm and a new Java program in that project folder named LuhnAlgorithm.java for this project. You can find a selection of valid-but-fake credit card numbers courtesy of PayPal at this link. Change the check digit on any of them to get an invalid number (note that your code should only use the 16 digit numbers and does not have to account for any of the card numbers that have any number of digits other than 16).
NOTE: You do NOT need to use arrays to solve this problem - this problem can be solved just with nested loops. Solutions that use an array where it isn't needed will be penalized in two ways: First, you're making the problem much harder than it needs to be, and second there will be a point deduction for use of an unnecessary array in the solution.
Sample Output: This is a sample transcript of what your program should do. Items in bold are user input and should not be put on the screen by your program.
Enter a credit card number (enter a blank line to quit): 5457623898234112 Check digit should be: 3 Check digit is: 2 Number is not valid. Enter a credit card number (enter a blank line to quit): 5457623898234113 Check digit should be: 3 Check digit is: 3 Number is valid. Enter a credit card number (enter a blank line to quit): 5555555555554 ERROR! Number MUST have exactly 16 digits. Enter a credit card number (enter a blank line to quit): 5555555555554445 Check digit should be: 4 Check digit is: 5 Number is not valid. Enter a credit card number (enter a blank line to quit): Goodbye!
import java.util.Scanner;
public class LuhnAlgorithm {
public static int Luhn(String credNum) {
int sum = 0;
for(int i = 15; i >= 0; i--) {
/* initializing i as 15, making sure the number is greater than 0, decrementing i */
if(i % 2 == 0) {
/* if int i is even */
int credDigit = 2*(credNum.charAt(i) - '0');
/*int credDigit is 2 times the number at the index listed */
if(credDigit > 9)
/* if the number doubled is in the double digits */
credDigit = ((credDigit % 10) - 9);
sum += credDigit;
/* subtract credDigit by 9 */
}
else
sum += (credNum.charAt(i) - '0');
/* Otherwise, add the number at the index listed to the sum */
}
sum -= (credNum.charAt(15) - '0');
return (10 - sum % 10);
/* returns the check digit */
}
In: Computer Science
Question 4
[25 marks]
[25 marks]
Downloaded Bitmap files or images have lower resolutions when
downloaded from the internet. Discuss into details how such files
or images can be resolved and printed on a large format printer
without losing its quality.
In: Computer Science
i could use the flowchart and pseudocode solutions for the following:
1. 1. Draw a structured flowchart describing the steps you would take to bake pancakes in a pan. Include at least one decision.
2. 2. Create the pseudocode to go along with the flowchart created in question above.
In: Computer Science
How can stakeholders and departments be involved during the cybersecurity policy life cycle?
In: Computer Science
C language you are to write a a program that will first read in the heights and weights of a series of people from a file named values.dat. Create this file using your editor so that each line contains a height and corresponding weight. For instance, it might look likea: 69.0 125.0 44.0 100.0 60.0 155.0 49.0 190.0 65.0 115.0 50.0 80.0 30.0 129.0 72.0 99.0 68.0 122.0 50.0 105.0 and so on.
The formula for the standard deviation of a series of numbers x[0], x[1] ... x[n] is std = sqrt( sum( (x[i] - xbar)**2 ) / (n) ) where xbar is the average value of x, n is the number of people, and **2 means squared.
------header file------
#define MAXNUM 100
typedef struct person
{
double height;
double weight;
} Person;
//prototypes follow:
int getData(FILE *input, Person people[]);
void getAverages(Person people[], double *aveHeight, double *aveWeight, int
numPeople);
void getStandardDevs(Person people[], double aveHeight, double aveWeight,
double *stdHeight, double *stdWeight, int numPeople);
--------main template ----------
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAXNUM 100
#include "stats.h"
void main( void )
{
FILE *input;
Person people[MAXNUM];
int numPeople = 0;
double aveHeight = 0.0, aveWeight = 0.0, stdHeight = 0.0, stdWeight = 0.0;
numPeople = getData(input, people);
getAverages(people, &aveHeight, &aveWeight, numPeople);
getStandardDevs(people, aveHeight, aveWeight, &stdHeight, &stdWeight, numPeople);
printf("\n\n\n\n\n\nThe average height is %lf\n", aveHeight);
printf("The average weight is %lf\n", aveWeight);
printf("The standard deviation of the heights is %lf\n", stdHeight);
printf("The standard deviation of the weights is %lf\n\n\n\n\n\n", stdWeight);
}
int getData( FILE* input, Person people[])
{
int numPeople = 0;
input = fopen( "values.dat", "r" ); // How to read file
if ( input == NULL )
{
printf( "\"values.dat\" does not exist!!\n" );
}
/*
your code here
*/
fclose(input);
return numPeople;
} // getData()
void getAverages( Person people[], double* aveHeight, double* aveWeight, int
numPeople)
{
/*
your code here
*/
} // getAverages()
void getStandardDevs( Person people[], double aveHeight, double aveWeight, double*
stdHeight, double* stdWeight, int numPeople )
{
/*
your code here
*/
} // getStandardDevs()
In: Computer Science