PK2A
5. How does the Supreme Court determine whether material is obscene?
6. Why have attempts to censor the Internet failed in the US?
7. Why not just ban spam?
8. Why did Facebook ban Alex Jones and Louis Farrakan?
9. Should websites that show how to 3d print guns be banned?
10. According to the Supreme Court 'anonymity is a shield from the tyranny of the majority'. What does that mean?
In: Computer Science
Write one Java application based on the following directions and
algorithms. Make sure the results from each of the bulleted items
is separate and easy to read/understand.
In: Computer Science
In: Computer Science
PYTHON: How do I split up the binary string into chunks of 8 so that they are converted from binary to ASCII characters? For example "0011101000101001" would be eventually converted to ":)" . The code I have below is what I currently have. It currently only works for binary strings of 8. argv[1] is the text file it is reading from and argv[2] is basically just 8.
import sys
filename=sys.argv[1]
length = int(sys.argv[2])
message_data = open(filename, "r")
message_text = message_data.read()
if len(message_text) == 0:
sys.exit(1)
a= message_text.replace(',','')
a= ''.join(a.split())
conversion_list =[128, 64, 32, 16, 8, 4, 2, 1]
dec=0
for position, digit in enumerate((a)):
dec += conversion_list[position]* int(digit)
print("Decimal is ",dec)
e=chr(dec)
In: Computer Science
Considering the following sequence of MIPS code, your task is to use pipelining building blocks to execute this set of instructions.
add $R2, $R0, $R0
lw $R1, 0($R2)
addi $R3, $R1, 20
add $R1, $R2, $R0
or $R1, $R2, $R0
A)
How many stall cycles would occur in a MIPS pipelining without Pipeline Forwarding? Using the pipelining building blocks to explain your result.
B)
How many stall cycles would occur in a MIPS pipelining with Pipeline Forwarding? We assume that Pipeline Forwarding exists between DM-to-ALU, ALU-to-ALU, and DM-to- DM. Using the pipelining building blocks to explain your result.
In: Computer Science
Budget Logistic Service operates a number of delivery vans. Each van is distinguished by its registration number, and characterized by the number of passenger seats and the maximal load weight. Budget Logistic operates various permanent delivery lines among the businesses in the neighborhood. Each line is assigned a unique number. A line has at least two stops: the origin and the destination. For a given line, a sequence of stops may exist between the origin and the destination. These stops also need to be recorded clearly as they will be used for scheduling purposes.That is, we need to be able to retrieve the origin, destination and all in-between stops if any. All stops are identified by street addresses. Some stops are shared by several lines. For each stop on each line, a specific time interval (i.e. waiting time) is prescribed for the driver to wait while the customers are bringing their packages. To avoid confusing customers, the waiting time does not depend on the day of the week or the hour. The management team of Budget Logistic keeps a schedule of lines, which fixes all the departure times (from the origin) of each line, on every day of the week. According to the load expectations, the dispatcher assigns one or more vans to each scheduled line. If no delivery jobs are expected on a certain line at a given time, then no vans are dispatched to depart on that line at that time. For each scheduled departure, the dispatcher records a brief advice to the driver, which is a short text.
Question: Construct the relational schema for the Budget Logistic database, based on the above description. Start an ER model then map it to the relational model. Your relational schema should have an adequate normalization up to Fourth normal form (4NF). For each relation you construct, define the primary key and indicate foreign keys, if any.
In: Computer Science
Given a queue of integers, write an algorithm and the program in c++ that, using only the queue ADT, calculates and prints the sum and the average of the integers in the queue without changing the contents of the queue.
In: Computer Science
For example, I have an input text file that reads:
"Hello, how are you?"
"You look good today."
"Today is a great day."
How can I write a function that inputs each line into a node in a linked list? Thank you. (Note: the input text files could have a different amount of lines, and some lines could be blank.)
This is the linked list code:
#include <iostream>
#include <cstdlib>
#include <fstream>
class Node
{
public:
Node* next;
int data;
};
using namespace std;
class LinkedList
{
public:
int length;
Node* head;
LinkedList();
~LinkedList();
void add(int data);
void print();
};
LinkedList::LinkedList(){
this->length = 0;
this->head = NULL;
}
LinkedList::~LinkedList(){
std::cout << "LIST DELETED";
}
void LinkedList::add(int data){
Node* node = new Node();
node->data = data;
node->next = this->head;
this->head = node;
this->length++;
}
void LinkedList::print(){
Node* head = this->head;
int i = 1;
while(head){
std::cout << i << ": " << head->data << std::endl;
head = head->next;
i++;
}
}
int main(int argc, char const *argv[])
{
LinkedList* list = new LinkedList();
list->print();
delete list;
return 0;
}
In: Computer Science
Java
. Implement a method that meets the following requirements: (a) Calls mergesort to sort an array/list of at least 5 integers (b) Prints the list before and after sorting.
In: Computer Science
Description: You are to develop a Java program that prints out the multiplication or addition table given the users start and end range and type of table. This time several classes will be used.
You are free to add more methods as you see fit – but all the methods listed below must be used in your solution.
For the class Table the following methods are required:
- Protected Constructor – stores the start and size of table, creates the correct size of array
- display() – displays with a good format (see A1a) a table
- For the classes AdditionTable and MultiplicationTable (separate files) the following methods should be made:
- Constructor – takes in start and end positions and calculates the table of values
- You will need to create an enumerated type (separate file) for the table types.
The driver (Main) class requires completion:
/**
* The driver program. Displays the specified arithmentic table with
* the specifified start/stop values.
*
*/
public final class Main
{
/**
* Disallow the creation of any Main objects.
*/
private Main()
{
}
/**
* The entry point to the program.
*
* @param argv the command line args.
* argv[0] - the type (+ or *)
* argv[1] - the start value (> 1 && < 100)
* argv[2] - the end value (> 1 && < 100)
*/
public static void main(final String[] argv)
{
final TableType type;
final int start;
final int stop;
final Table table;
if(argv.length != 3) {
usage();
}
type = getType(argv[0]);
start = getNumber(argv[1]);
stop = getNumber(argv[2]);
table = getTable(type, start, stop);
//YOUR CODE TO DISPLAY TABLE – HINT 1 LINE OF CODE!
}
/**
* Convert the supplied string into the appropriate TableType.
* If the string is not a valid type then exit the program.
*
* @param str the stringto convert
* @return the appropriate TableType
*/
public static TableType getType(final String str)
{
final TableType type;
if(str.equals("+"))
{
type = TableType.ADD;
}
else if(str.equals("*"))
{
type = TableType.MULT;
}
else
{
usage();
type = null;
}
return (type);
}
/**
* Convert the supplied string into an int.
* If the string is not a valid int then exit the program.
* To be valid the string must be an integer and be > 0 and < 100.
*
* @param str the string to convert
* @return the converted number
*/
public static int getNumber(final String str)
{
int val;
try
{
val = Integer.parseInt(str);
if(val < 1 || val > 100)
{
usage();
}
}
catch(final NumberFormatException ex)
{
usage();
val = 0;
}
return (val);
}
public static Table getTable(final TableType type,
final int width,
final int height)
{
//YOUR CODE GOES HERE
}
/**
* Display the usage message and exit the program.
*/
public static void usage()
{
System.err.println("Usage: Main <type> <start> <stop>");
System.err.println("\tWhere <type> is one of +, \"*\"");
System.err.println("\tand <start> is between 1 and 100");
System.err.println("\tand <stop> is between 1 and 100");
System.err.println("\tand start < stop");
System.exit(1);
}
}
In: Computer Science
PART A
Write a program that converts a total number of seconds to
hours, minutes, and seconds.
It should do the following:
Your output must be of the format:
totalSeconds seconds = numHours hours,
numMinutes minutes, and numSeconds seconds
For example:
If the user entered: 5000
Your program would output:
5000 seconds = 1 hours, 23 minutes, and 20 seconds
5000 seconds = 01h:23m:20s
Sample run would look like:
Enter the number of seconds: 5000
5000 seconds = 1 hours, 23 minutes, and 20 seconds
5000 seconds = 01h:23m:20s
Sample run would look like:
Enter the number of seconds: 3754
3754 seconds = 1 hours, 2 minutes, and 34 seconds
3754 seconds = 01h:02m:34s
Hint1:Use integer division
Hint2: Use the modulus operator
Please make sure to end each line of output with a
newline.
Please note that your class should be named
SecondsConverter.
PART B
Write a program that converts change into formatted dollars and cents It should do the following:
Your output must be of the format: (plural is ok even when grammatically incorrect)
You entered: 6 quarters 5 dimes 4 nickels 3 pennies The total in dollars is $2.23
Sample run would look like:
Enter the number of quarters: 6 Enter the number of dimes: 5 Enter the number of nickels: 4 Enter the number of pennies: 3 You entered: 6 quarters 5 dimes 4 nickels 3 pennies The total in dollars is $2.23
Sample run would look like:
Enter the number of quarters: 1 Enter the number of dimes: 2 Enter the number of nickels: 3 Enter the number of pennies: 2 You entered: 1 quarters 2 dimes 3 nickels 2 pennies The total in dollars is $0.62
Hint1: Use printf and be sure to have at least 1 digit to the left of the decimal, and a max of 2 floating on the right.
Please make sure to end each line of output with a
newline.
Please note that your class should be named
ChangeConverter.
PART C
Write a program that converts a temperature from
Celsius to Fahrenheit.
It should do the following:
Your prompt to the user to enter the temperature in Celsius must be: Enter the Celsius Temperature as a decimal:
Your output must be of the format: celsiusTemperature C = fahrenheitTemperature F
For example: If the user entered: 24.0
Your program would output: 24.0 C = 75.2 F
Sample run would look like:
Enter the temperature in degrees
celsius: 24
24.0 C = 75.2 F
Sample run would look like:
Enter the temperature in degrees
celsius: 7.5
7.5 C = 45.5 F
Hint1: Be careful not to use integer
division!
Here is the formula F = ( C * 9 / 5 ) +
32
Hint2: Remember to use printf to format the
output.
Please make sure to end each line of output with a newline.
Please note that your class should be named
CelsiusToFahrenheit.
In: Computer Science
I need an answer only for the bold part of the question.
1. Circle:
The class has two private instance variables: radius (of the type double) and color (of the type String).
The class also has a private static variable: numOfCircles (of the type long) which at all times will keep track of the number of Circle objects that were instantiated.
Construction:
A constructor that constructs a circle with the given color and sets the radius to a default value of 1.0.
A constructor that constructs a circle with the given, radius and color.
Once constructed, the value of the radius must be immutable (cannot be allowed to be modified)
Behaviors:
Accessor and Mutator aka Getter and Setter for the color attribute
Accessor for the radius.
getArea() and getCircumference() methods, hat return the area and circumference of this Circle in double.
Hint: use Math.PI (https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#PI (Links to an external site.))
2. Rectangle:
The class has two private instance variables: width and height (of the type double)
The class also has a private static variable: numOfRectangles (of the type long) which at all times will keep track of the number of Rectangle objects that were instantiated.
Construction:
A constructor that constructs a Rectangle with the given width and height.
A default constructor.
Behaviors:
Accessor and Mutator aka Getter and Setter for both member variables.
getArea() and getCircumference() methods, that return the area and circumference of this Rectangle in double.
a boolean method isSquare(), that returns true is this Rectangle is a square.
Hint: read the first 10 pages of Chapter 5 in your text.
3. Container
The class has two private instance variables: rectangle of type Rectangle and circle of type Circle.
Construction:
No explicit constructors.
Behaviors:
Accessor and Mutator aka Getter and Setter for both member variables.
an integer method size(), that returns 0, if all member variables are null, 1 either of the two member variables contains a value other than null, and 2, if both, the rectangle and circle contain values other than null.
In: Computer Science
Note- can you rewrite the code in C++.
Circle Class c++ code Write a circle class that has the following member variables:
• radius: a double
• pi: a double initialized with the value 3.14159
The class should have the following member functions:
• Default Constructor. A default constructor that sets radius to 0.0.
• Constructor. Accepts the radius of the circle as an argument
. • setRadius. A mutator function for the radius variable.
• getRadius. An acccssor function for the radius variable
. • getArea. Returns the area of the circle, which is calculated as
area = pi * radius * radius
• getDiameter. Returns the diameter of the circle, which is calculated as
diameter = radius * 2
• getcircumforence. Returns the circumference of the circle, which is calculated as
circumference = 2 * pi * radius
Write a program that demonstrates the circle class by asking the user for the circle's radius, creating a circle object, and then reporting the circle's area, diameter, and circumference.
In: Computer Science
Create a new SQL Developer SQL worksheet and create/run the following TWO (2) queries and save your file as Comp2138LabTest1_JohnSmith100123456.sql (replace JohnSmith 100123456 with your name and student ID). Please place comment that includes your name and your student ID at the top of your script and number your queries using comments sections. Each query carries equal weight. A selection of the expected result set has been shown below for your convenience. Your output should match with this sample output. PAY SPECIAL ATTENTION TO COLUMN NAMES.
1. Use the Dual table to create a row with these columns: Starting Principal New Principal Interest Principal + Interest Starting principle which should be equal to $51,000 Starting principal plus a 10% increase 6.5% of the new principal The new principal plus the interest (add the expression you used for the new principal calculation to the expression you used for the interest calculation) Now, add a column named “System Date” that uses the TO_CHAR function to show the results of the SYSDATE function when it’s displayed with this format: 'dd-mon-yyyy hh24:mi:ss' This format will display the day, month, year, hours, minutes, and seconds of the system date, and this will show that the system date also includes a time. The query would return only one row as shown here
2. Write a SELECT statement that returns one row for each general ledger account number that contains three columns: The account_description column from the General_Ledger_Accounts table The count of the entries in the Invoice_Line_Items table that have the same account_number The sum of the line item amounts in the Invoice_Line_Items table that have the same account-number Filter for invoices dated in the second quarter of 2014 (April 1, 2014 to June 30, 2014). Include only those rows with a count greater than 1; group the result set by account description; and sort the result set in descending sequence by the sum of the line item amounts. [schema: ap] The query would return 13 rows as shown here
In: Computer Science
i need the whole html code Make a layout template that contains a header and two paragraphs. Use float to line up the two paragraphs as columns side by side. Give the header and two paragraphs a border and/or a background color so you can see where they are.
In: Computer Science