What method does NOT cause the program to wait until a stream's buffer is empty? (a) flush (b) endl (c) clear (d) close (e) Multiple answers don't pause the program. (f) None of the above cause the program to pause.
I believe that clear is the answer.
flush pauses the program, endl (indirectly calls flush), close (calls flush).
In: Computer Science
General Questions about Network Footprinting
Guidelines
1. What is accomplished by network footprinting?
2. What are the countermeasures a network security architect can set in motion to diminish the threat from network footprinting?
3. What is the difference between network footprinting and
network reconnaissance?
4. In the context of network security, explain what is meant by
after reconnaissance comes penetration.
5. What is a denial of service (DOS) attack?
In: Computer Science
Write a function that will take a string containing only alphanumeric characters that are in lowercase (if you think your logic requires you to use more than one argument, please go ahead). Your task is to see if the string becomes a palindrome if only one character is removed from anywhere in the string.
In: Computer Science
Python:
You will modify the given code to create a guessing game that takes user input and allows you to make multiple guesses. There should also be a loop
Use the following attached Sample Code as a guide.
There are mistakes in the code!!!
#Guessing Game
import random
number=random.randint(1, another number)
print("Hello, CIS 101")
print("Let's play a guessing Game!called guess my number.")
print("The rules are: ")
print("I think of a number and you'll have to guess it.")
guess = random.randint(1, 5)
print("You will have " + str(guess) + " guesses.")
YourNumber = ???
unusedguesses=int(guess)
while unusedguesses < guess:
if int(YourNumber) == number:
print("YAY, You have guessed my number")
else:
unusedguesses=int(guess)-1
if unusedguesses == 0:
break
else:
print("Try again!")
print("The number was ", str(number))
In: Computer Science
Activity 10: Review
Comparison Operators
Comparison operators allow you to test whether values are
equivalent or whether values are identical.
Conditional Code
Sometimes you only want to run a block of code under certain
conditions. Flow control — via if and else blocks — lets you run
code only under certain conditions.
Switch Statement
Rather than using a series of if/else if/else blocks, sometimes it
can be useful to use a switch statement instead. [Definition:
Switch statements look at the value of a variable or expression,
and run different blocks of code depending on the value.]
Loops
Loops let you run a block of code a certain number of times. Note
that in Loops even though we use the keyword var before the
variable name i, this does not “scope” the variable i to the loop
block
For Loop
A for loop is made up of four statements and has the following
structure:
The initialisation statement is executed only once, before the loop
starts. It gives you an opportunity to prepare or declare any
variables.
The conditional statement is executed before each iteration, and
its return value decides whether or not the loop is to continue. If
the conditional statement evaluates to a falsey value then the loop
stops.
The iteration statement is executed at the end of each iteration
and gives you an opportunity to change the state of important
variables. Typically, this will involve incrementing or
decrementing a counter and thus bringing the loop ever closer to
its end.
The loopBody statement is what runs on every iteration. It can
contain anything you want. You’ll typically have multiple
statements that need to be executed and so will wrap them in a
block ( {...}).
While Loop
A while loop is similar to an if statement, except that its body
will keep executing until the condition evaluates to false.
An example for a while loop:
The do-while loop
This is almost exactly the same as the while loop, except for the
fact that the loop’s body is executed at least once before the
condition is tested.
An example for a do-while loop:
Functions
Functions contain blocks of code that need to be executed
repeatedly. Functions can take zero or more arguments, and can
optionally return a value.
Functions can be created in a variety of ways:
Function Declaration
Named Function Expression
A Simple Function
A Function Returns a Value
A Function that Returns another Function
A Self-executing Anonymous Function
A common pattern in JavaScript is the self-executing anonymous
function. This pattern creates a function expression and then
immediately executes the function. This pattern is extremely useful
for cases where you want to avoid polluting the global namespace
with your code — no variables declared inside of the function are
visible outside of it.
Function as Arguments
In JavaScript, functions are “first-class citizens” — they can be
assigned to variables or passed to other
functions as arguments. Passing functions as arguments is an
extremely common idiom in jQuery.
• Passing an anonymous function as an argument
• Passing a named function as an argument
Task 1 – Write web program to calculate a class average mark. It
should allow users to enter one mark at time for 3 times. See
Lesson 10 slides 33-35 for references.
Task 2 – Write web program to calculate a class average mark. It
should allow users to enter one mark at time for as many times as
they wish to do so. It also allows user to stop by entering
-1.
In: Computer Science
1. WRITE 3 ACTIVITIES AT EACH TIME MENTION (MORNING, AFTERNOON / EVENING, NIGHT) THAT YOU DO / SPEND TIME TOGETHER WITH YOUR FRIENDS.
2. DESCRIBE THE ACTIVITIES AT EACH TIME IN 7-10 SENTENCES IN A PARAGRAPH WITH RELEVANT PICTURES.
In: Computer Science
Hi!
I 'm writing a code for a doubly linked list and this is the header file
#include<iostream>
#include <string>
using namespace std;
struct node
{
int data;
node *next,*prev;
node(int d,node *p=0,node *n=0)
{
data=d; prev=p; next=n;
}
};
class list
{
node *head,*tail;
public:
list();
bool is_empty();
int size();
void print();
void search();
int search2(int el);
void add_last(int el);
void add_first(int el);
bool add_pos();
bool delete_first();
bool delete_last();
void delete_pos(int pos);
void delete_el();
void add_sorted();
};
i want to write a function that split the list into 2 list from a specific number
ex. 5 4 7 2 8
if I spilt it from number 4 it will be 5 in the first list and 7 2 8 in the second list and number 4 will go to the List that contains fewer element so first list will have 5 4 and second list 7 2 8 if the have the same number of element the number that you were separated from it goes to any list it does not matter
In: Computer Science
Create an ER diagram, a Relational Schema, and tables with Data, based on the following requirements:
The database will keep track of students and campus organizations.
- For each student, we will keep track of his or her unique student ID, and his or her name and gender.
- For each organization, we will keep track of its unique organization ID and the location.
- Each student in the database belongs to at least one organization and can belong to multiple organizations.
- Each organization in the database has at least one student belonging to it and can have multiple students.
- For every instance of a student belonging to an organization, we will record the student's function in the organization (e.g., president, vice president, treasurer, member, etc.).
In: Computer Science
unix operating system
create the scripts in your Fedora Server Virtual Machine
1- Open the file lab1 located in the labs directory and create a script that prompts the user to enter name, address and phone #. All entered details are directed to file "info.txt" in the same directory
When display info.txt, it should look like this example:
Name: John Smith
Address: 31-10 Thomson Ave.
Phone: 718-482-0000
2- Open the file lab2 located in the labs directory and create a script to display the logged in user name and user UID
When you execute lab2, the output should look like this example:
Username: root
User ID: 0
In: Computer Science
Research cyber kill chains. Is this a legit "game changer" in the IR space? How so?
Give a specific example
In: Computer Science
PROGRAM SIMULATION. Understand the given JAVA program and write the output.
1. public class Places
{
public static void main(String args[])
{
String place[]=new String[4];
place[0]="Salmaniya";
place[1]="Salmabad";
place[2]="Isa Town";
place[3] = “Manama”
System.out.println(place[3]);
System.out.println(place[1].toLowerCase());
System.out.println(place[2].substring(4,6);
System.out.println(place[3].charAt(4));
System.out.println(place[1].equals(place[2]));
}
}
b. public class ChangeIt
{
public void doIt( int[] z )
{
z[0] = 0;
}
}
public class TestIt
{
public static void main ( String[] args )
{
int[] myArray = {1, 2, 3, 4, 5} ;
ChangeIt.doIt(myArray );
for (int j=0; j<myArray.length; j++ )
System.out.print( myArray[j] + " " ) ;
}
}
In: Computer Science
In Java, what is the advantage of using ArrayList over arrays?
Write a program to perform following operations
a. Create a class named Rectangle with two
properties “height” and “width”. Create a parameterized
constructor to initialize “height” and “width” values.
b. Write method area() to calculate and return area of
Rectangle.
c. Create an ArrayList to store Rectangle objects.
d. Create three Rectangle objects of width and height set to
(2, 3), (3, 3) and (4, 5) and add them to ArrayList.
e. Calculate and print area of all the Rectangle objects in
ArrayList. (Hint: Area = height x width)
In: Computer Science
Activity 11: JS-Loops and Functions
Task 1:
Use JavaScript for loop to print the first 5 non-zero integers on
each line.
Task 2:
Use JavaScript while loop to print the first 5 non-zero integers on
each line.
Task 3:
Use JavaScript for loop to print the first 5 even integers on each
line.
Task 4:
Write a JavaScript function to multiple two numbers and return the
result.
Task 5:
Write a JavaScript factorial that asks users to enter a positive
and return the result.
i) Without using recursion ii) Using recursion Task 6:
Use a nested for or while loop to produce a table below.
1,1 1,2 1,3 1,4 1,5
2,1 2,2 2,3 2,4 2,5
3,1 3,2 3,3 3,4 3,5
4,1 4,2 4,3 4,4 4,5
5,1 5,2 5,3 5,4 5,5
In: Computer Science
In: Computer Science
You built your own 3D printer and intend to make a business of
printing small parts for customers. After advertising your business
on campus, you receive hundreds of emails within the span of a few
days - all of which are fellow students asking for quotes on
printing their parts. You go through all of the STL files, and
record the approximate print time, material use and cost estimates
for each as follows: Order 1: Order 2: Print Time: 43 minutes Print
Time: 28 minutes Colour: Red Colour: Blue Material: 1.64 feet
Material: 0.91 feet Cost: 3.80 $USD Cost: 2.11 $USD Order #: Print
Time: ## minutes Colour: ... Material: #### feet Cost: #.## $ USD
You've recorded each customer order as shown above and intend to
start completing orders next week. Before hand, you want to know
the total amount of time the printing will take, the total amount
of material for each colour filament that you need to have on hand
and the total material costs. Seeing as there are hundreds of
orders on file you don't want to do these calculations manually, so
you decide to use Python instead. In this assignment, you will be
completing the function definition printing(orders), which has been
started for you in the code template notebook. This function takes
in a list of strings orders, where each element in the list is one
line from the orders file, such as: orders = ["Order 1:\tPrint
Time: 43 minutes\tColour: Red\tMaterial: 1.64 feet\tCost: 3.80
$USD", "Order 2:\tPrint Time: 28 minutes \tColour: Blue \tMaterial:
0.91 feet\tCost: 2.11 $USD"] You must complete the function
definition to satisfy the following requirements: 1. The program
computes the following 3 values: a. printTime = the total print
time for all orders, stored in a list: [hours, minutes] b. matlused
= the total material used for all orders, stored in a list based on
filament color: [Red_matlused, Blue_matlused, Yellow_matlused,
White_matlused, Black_matlused). Since your filament provider is
based out of Canada, you need to provide this measurement in metres
(1 metre = 3.28 feet). c. matlCost = the total material cost in
$CAD (1 $USD = 1.42 $CAD). d. profit = your estimated profit if you
charge 0.25 SCAD/minute of printing and only account for the
material cost in your expenses (profit = revenue - expenses). 2.
The program returns print Time, matlused, matlCost, and profit as
output (done for you in the code given). 3. Your name, Maced, and
the date are given in comments in the first Python cell. 4. Your
answers to the design questions and test plan are given in the
appropriate cells in the Python notebook. 5. Your program MUST have
valid Python syntax and it must run without errors. Ensure that
your
# Date: In [ ]: ######################################--
printing(orders) ###################################### def
printing (orders): # Modify/add to the code between here...
printTime = [] matlused = [0,0,0,0,0] matlCost = 0 profit = 0 #...
and here return printTime, matlused, matlcost, profit
##########---TEST YOUR CODE---#################### # Change the
values of orderTest to test with different values orderTest =
["order 1:\tPrint Time: 43 minutes\tcolour: Red\tMaterial: 1.64
feet\tCost: 3.80 $USD", "Order 2: \tPrint Time: 28 minutes\tcolour:
Blue\tMaterial: 0.91 feet\tCost: 2.11 $USD"] result = printing
(orderTest) ############## print("printTime=" ', result[0])
print("matlused =", result[1]) print("matlCost , result[2])
print("profit=" ", result[3])
In: Computer Science