Questions
package applications; public class Matrix { private int[][] m; public Matrix(int x, int y) { m...

package applications;

public class Matrix

{

private int[][] m;

public Matrix(int x, int y)

{

m = new int[x][y];

}

public Matrix(int x, int y, int z)

{

m = new int[x][y];

for(int i = 0; i < x; i++)

{

for(int j = 0; j < y; j++)

{

m[i][j] = z;

}

}

}

public int rowsum(int i) throws IndexOutOfBoundsException

{

if (i < 0 || i > m.length-1)

{

throw new IndexOutOfBoundsException("Invalid Row");

}

int sum = 0;

for(int j = 0; j < m[i].length; j++)

{

sum += m[i][j];

}

return sum;

}

public static void main(String[] args)

{

Matrix A = new Matrix(100, 100, 1);

System.out.println(A.rowsum(99));

System.out.println("Done!");

Matrix B = new Matrix(1000, 1000, 1);

System.out.println("Done!");

Matrix C = new Matrix(10000, 10000, 1);

System.out.println("Done!");

}

}

1)add method columnSum(j)

2)add method max() which returns the largest value that contain in the matrix

3)add method trace() i.e., if matrix is not square, then throw error otherwise compute the sum of the entries on the diagnol.

In: Computer Science

Fill in each blank with the correct answer/output. Assume each statement happens in order and that...

Fill in each blank with the correct answer/output. Assume each statement happens in order and that one statement may affect the next statement. Hand trace this code instead of using your IDE. String s = "abcdefghijklmnop"; ArrayList r = new ArrayList(); r.add("abc"); r.add("cde"); r.set(1,"789"); r.add("xyz"); r.add("123"); Collections.sort(r); r.remove(2); The first index position in an array is __________. System.out.print( s.substring(0,1) ); // LINE 2 System.out.print( s.substring(2,3) ); // LINE 3 System.out.print( s.substring(5,6) ); // LINE 4 System.out.print( r.get(0) ); // LINE 5 System.out.print(r.get(0).substring(0,1)); // LINE 6 System.out.print( r.get(2) ); // LINE 7 System.out.print( r.indexOf("123")); // LINE 8 System.out.print( r.contains("abc")); // LINE 9 System.out.print( r.isEmpty()); // LINE 10 r.set(1, "\\\\"); System.out.print(r); // LINE 11 r.remove(1); System.out.print(r); // LINE 12 r.add("one"); System.out.print(r); // LINE 13 r.add(0,"five"); System.out.print(r); // LINE 14 r.clear(); System.out.print(r); // LINE 15 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15.

In: Computer Science

_______ are small central processing units chips. in the expression 12.45 + 3.6, the values to...

_______ are small central processing units chips.

in the expression 12.45 + 3.6, the values to the right and left of the + symbol are the______

python uses______ to categorize values in memory.

the% symbol is the remainder operator. also known as the______ operator.

when applying the .3f formatting specifier er to the number 76.15854, the result is____.

In: Computer Science

Assume a byte-addressable memory has 64K bytes. Blocks are 8 bytes in length and the cache...

Assume a byte-addressable memory has 64K bytes. Blocks are 8 bytes in length and the cache consists of 4K bytes. Show the format for a main memory address assuming a 4-way set associative cache mapping scheme. Include the field names as well as their sizes.

In: Computer Science

Write a java script function that accepts integer array as input, and display a new array...

Write a java script function that accepts integer array as input, and display a new array by

performing fol

lowing modifications,

The values in odd index positions must be incremented by 1

The values in even index positions must be decremented by 1.

Assume the array index starts from 0.

Input 1: arr = [1,2,3,4]

Output 1: arr = [0,3,2,5

it done html and javascript and plz do it in simple way

In: Computer Science

Create a class called triangle_area. The initializing inputs are numbers b and h. In addition to...

Create a class called triangle_area. The initializing inputs are numbers b and h. In addition to the initialization method, the class must have the area method, which calculates the area of ​​a triangle (A = b x h / 2) and creates an attribute called Area with that value.

Use python sintaxis

In: Computer Science

Instructions Write a program to implement the algorithm that you designed in Exercise 19 of Chapter...

Instructions

Write a program to implement the algorithm that you designed in Exercise 19 of Chapter 1.

Your program should allow the user to buy as many items as the user desires.

Instructions for Exercise 19 of Chapter 1 have been posted below for your convenience.

TEXT ONLY PLEASE (PLEASE NO PDF OR WRITING)

C++ CODE

Exercise 19

Jason typically uses the Internet to buy various items. If the total cost of the items ordered, at one time, is $200 or more, then the shipping and handling is free; otherwise, the shipping and handling is $10 per item. Design an algorithm that prompts Jason to enter the number of items ordered and the price of each item. The algorithm then outputs the total shipping and handling fee, and the billing amount. Your algorithm must use a loop (repetition structure) to get the price of each item. (For simplicity, you may assume that Jason orders no more than five items at a time.)

An example of the program is shown below:

Enter the number of items ordered: 3

Enter the price of item no. 1: 79.00

Enter the price of item no. 2: 23.50

Enter the price of item no. 3: 1.99

The shipping and handling fee is: $30.00
The billing amount is: $134.49

Since your program handles currency, make sure to use a data type that can store decimals with a decimal precision of 2.

In: Computer Science

10.5 LAB: Air-traffic control (queue using a linked list) Given a partial main() and PlaneQueue class,...

10.5 LAB: Air-traffic control (queue using a linked list)

Given a partial main() and PlaneQueue class, write the push() and pop() methods for PlaneQueue. Then complete the main() to read in whether flights are arriving or have landed at an airport. An "arriving" flight is pushed onto the queue. A "landed" flight is popped from the front of the queue. Output the queue after each plane is pushed or popped. Entering -1 exits the program.

Ex: If the input is:

arriving AA213
arriving DAL23
arriving UA628
landed
-1

the output is:

Air-traffic control queue
   Next to land: AA213

Air-traffic control queue
   Next to land: AA213
   Arriving flights: 
      DAL23

Air-traffic control queue
   Next to land: AA213
   Arriving flights: 
      DAL23
      UA628

AA213 has landed.
Air-traffic control queue
   Next to land: DAL23
   Arriving flights: 
      UA628

AirTrafficControl.java

import java.util.Scanner;

public class AirTrafficControl {

public static void main (String[] args) {
Scanner scnr = new Scanner(System.in);
  
PlaneQueue planeQueue = new PlaneQueue();
  
PlaneNode curNode;
PlaneNode foundNode;
String arrivingOrLanded;
String flightCode;
  
// TODO: Complete main to read in arriving flight codes and whether
// a flight has landed. Print the queue after every push() or
// pop() operation. If the user entered "landed", print which
// flight has landed. Continue until -1 is read.
  
}
}

PlaneQueue.javapublic class PlaneQueue {
private PlaneList planeList; // Queue implemented using linked list
int length;

public PlaneQueue() {
planeList = new PlaneList();
length = 0;
}

// TODO: Write push() and pop() methods. push() adds an item to
// the queue and increases the length by 1. pop() removes and
// returns the first item in the queue and decreases the length by 1.

public boolean isEmpty() {
if (length == 0) {
return true;
}
return false;
}

public int getLength() {
return length;
}

public void printPlaneQueue() {
PlaneNode curNode;

curNode = planeList.headNode;
System.out.println("Air-traffic control queue");
if (!isEmpty()) {
System.out.print(" Next to land: ");
curNode.printNodeData();
System.out.println();
  
if (length > 1) {
System.out.println(" Arriving flights: ");
curNode = curNode.nextNode;
while (curNode != null) {
System.out.print(" ");
curNode.printNodeData();
System.out.println();
curNode = curNode.nextNode;
}


}
}
  
else {
System.out.println("Queue is empty.\n");
}
System.out.println();
}
}

PlaneList.java

public class PlaneList {
// Linked list nodes
public PlaneNode headNode;
public PlaneNode tailNode;

public PlaneList() {
// Front of nodes list   
headNode = null;
tailNode = null;
}

// append
public void append(PlaneNode newNode) {
if (headNode == null) { // List empty
headNode = newNode;
tailNode = newNode;
}
else {
tailNode.nextNode = newNode;
tailNode = newNode;
}
}

// prepend
public void prepend(PlaneNode newNode) {
if (headNode == null) { // list empty
headNode = newNode;
tailNode = newNode;
}
else {
newNode.nextNode = headNode;
headNode = newNode;
}
}

// insertAfter
public void insertAfter(PlaneNode curNode, PlaneNode newNode) {
if (headNode == null) { // List empty
headNode = newNode;
tailNode = newNode;
}
else if (curNode == tailNode) { // Insert after tail
tailNode.nextNode = newNode;
tailNode = newNode;
}
else {
newNode.nextNode = curNode.nextNode;
curNode.nextNode = newNode;
}
}

// removeAfter
public void removeAfter(PlaneNode curNode) {
PlaneNode sucNode;
  
// Special case, remove head
if (curNode == null && headNode != null) {
sucNode = headNode.nextNode;
headNode = sucNode;

if (sucNode == null) { // Removed last item
tailNode = null;
}
}
else if (curNode.nextNode != null) {
sucNode = curNode.nextNode.nextNode;
curNode.nextNode = sucNode;

if (sucNode == null) { // Removed tail
tailNode = curNode;
}
}
}

// search
public PlaneNode search(String key) {
PlaneNode curNode;
int position = 1;
  
curNode = headNode;
while (curNode != null) {
curNode.nodePos = position;
if (curNode.flightCode.equals(key)) {
return curNode;
}
curNode = curNode.nextNode;
++position;
}
return null;
}

public void printPlaneList() {
PlaneNode curNode;

curNode = headNode;
while (curNode != null) {
curNode.printNodeData();
System.out.println();
curNode = curNode.nextNode;
}
}
}

PlaneNode.java

public class PlaneNode {
public String flightCode;
public PlaneNode nextNode; // Reference to the next node
public int nodePos;

public PlaneNode() {
flightCode = "0";
nextNode = null;
}

// Constructor   
public PlaneNode(String initFlightCode) {
this.flightCode = initFlightCode;
this.nextNode = null;
}

// Constructor   
public PlaneNode(String initFlightCode, PlaneNode newNextNode) {
this.flightCode = initFlightCode;
this.nextNode = newNextNode;
}

public void printNodeData() {
System.out.print(this.flightCode);
}
}

In: Computer Science

Thoroughly discuss and answer the following question. Do some research and find out whether Babbage’s Analytical...

Thoroughly discuss and answer the following question. Do some research and find out whether Babbage’s Analytical Engine is a computer according to the von Neumann model. Post a complete answer to the best of your abilities and research and understanding. Reference your sources other than textbook.

In: Computer Science

Policy Drivers The purpose of this assignment is to practice and demonstrate your ability to interpret...

Policy Drivers

The purpose of this assignment is to practice and demonstrate your ability to interpret detailed policy. We have chosen for you to take a look at two of the most well known policies; in real life, you will have government polices such as these as well as enterprise specific policies or regulations. As you build information systems, it is key to early on in the process to identify all relevant policy drivers and understand them.

In the module, we discussed how an organization's policies and regulations for data governance influence the nature and structure of IT/IS systems. For your assignment, research either HIPAA (for health care) or Sarbanes-Oxley (for financial data). In 1 page, describe at least two of the policies you find and explain how an IT/IS system would need to accommodate.

In: Computer Science

Create a Java method that does the following: 1) Ask the user for a dividend and...

Create a Java method that does the following: 1) Ask the user for a dividend and a divisor both of "int" type. 2) Computes the remainder of the division. The quotient (answer) must be of the "int" type. Do NOT use the method " % " provided in Java in your code. Remember that it gives wrong answers when some of the inputs are negative. Please see the videos for the explanation. This is the code I have from the previous work that should be modified to fit this problem:

import java.util.Scanner;

public class DivisionAlgorithm {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

int n1, n2;

System.out.print("Enter dividend input: ");

n1 = scanner.nextInt();

System.out.print("Enter divisor input: ");

n2 = scanner.nextInt();

while(n1>=n2){

n1 = n1 - n2;

}

System.out.println("Quotient = "+n1);

}

}

-22 / 3 doesn't compute correctly, negative numbers return with errors.

In: Computer Science

For this assignment you will implememnt a number of Boolean functions, such as implies, nand, etc....

For this assignment you will implememnt a number of Boolean functions, such as implies, nand, etc.

a) Boolean functions You are provided with a set of undefined functions.You will create the bodies for these 2 parameter functions, such that they return the appropriate Boolean value (True or False). The formal parameters are always p and q (in that order)

Notice the difference between npIMPnq and nqIMPnp: In npIMPnq you return not p implies not q (not first param implies not second param), for example npIMPnq(True,False) returns True.

In nqIMPnp you return not q implies not p (not second param implies not first param), for example nqIMPnp(True,False) returns False.

b) Truth-table inputs The function makettins(n) will create a truth table for all combinations of n Boolean variables. A truth table is an arrayList of 2**n arrayLists of n Booleans. For example makettins(2) returns
[[False, False], [False, True], [True, False], [True, True]]

Notice the recursive nature of makettins(n): It consists of a truth-table(n-1), each row prefixed with False followed by the same truth-table(n-1), each row prefixed with True, with a base case for n==1: [[False], [True]]

Two functions are provided: run(f) and main, so that you can test your code.

'''
PA1: Boolean functions and truth-table inputs
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

For PA1 you will implememnt a number of Boolean functions,
such as implies, nand, etc.

a) Boolean functions
You are provided with a set of undefined functions.You will
create the bodies for these 2 parameter functions, such that
they return the appropriate Boolean value (True or False).
The formal parameters are always p and q (in that order)

Notice the difference between npIMPnq and nqIMPnp:
In npIMPnq you return not p implies not q (not first
param implies not second param), for example
npIMPnq(True,False) returns True.

In nqIMPnp you return not q implies not p (not second
param implies not first param), for example
nqIMPnp(True,False) returns False.

b) Truth-table inputs
The function make_tt_ins(n) will create a truth table for
all combinations of n Boolean variables. A truth table is
an arrayList of 2**n arrayLists of n Booleans. For example
make_tt_ins(2) returns
[[False, False], [False, True], [True, False], [True, True]]

Notice the recursive nature of make_tt_ins(n):
It consists of a truth-table(n-1), each row prefixed with False
followed by the same truth-table(n-1), each row prefixed with True,
with a base case for n==1: [[False], [True]]

Two functions are provided: run(f) and main, so that you can test
your code.

python3 PA1.py tests your Boolean function
python3 PA1.p=y tt tests your function make_tt_ins()

'''


import sys

# p implies q
def implies(p, q):
return False
# not p implies not q
def npIMPnq(p,q):
return False

# not q implies not p
def nqIMPnp(p,q):
return False

# p if and only if q: (p implies q) and (q implies p)
def iff(p, q):
return False

# not ( p and q )
def nand(p, q):
return False

# not p and not q
def npANDnq(p,q):
return False

# not ( p or q)
def nor(p, q):
return False

# not p or not q
def npORnq(p,q):
return False

def make_tt_ins(n):

return [[]]

#provided
def run(f):
print(" True,True : ", f(True,True))
print(" True,False : ", f(True,False))
print(" False,True : ", f(False,True))
print(" False,False: ", f(False,False))
print()
  
#provided
if __name__ == "__main__":
print("program", sys.argv[0])
f1 = sys.argv[1]
print(f1);
if(f1 == "implies"):
run(implies);
if(f1 == "iff"):
run(iff)
if(f1 == "npIMPnq"):
run(npIMPnq)
if(f1 == "nqIMPnp"):
run(nqIMPnp)
if(f1 == "nand"):
run(nand)
if(f1 == "nor"):
run(nor)
if(f1 == "npANDnq"):
run(npANDnq)
if(f1 == "npORnq"):
run(npORnq)
if(f1 == "tt"):
print(make_tt_ins(int(sys.argv[2])))
  

In: Computer Science

Your supervisor, Sophia, has recommended the company's mail server or website as the best potential systems...

Your supervisor, Sophia, has recommended the company's mail server or website as the best potential systems to consider. You should review the issues associated with both a mail server and website migration, and then make a decision as to which system that you propose migrating

  • select either the mail server or website for migration.

Week 1 Deliverable:

Write a 1 page executive summary explaining the legacy system that you have chosen to migrate, your reasoning for making that choice, and a brief analysis of the issues that you will need to consider.

In: Computer Science

From the security aspect of client/browser, connecting to a secure web site/server, From the cyber security...

From the security aspect of client/browser, connecting to a secure web site/server,

  1. From the cyber security perspective, what browser features should be examined for valid certificates.
  2. What are the risks of using expired web certificates

In: Computer Science

USING C++ 1) Write a program that repeatedly evaluates a n-th order polynomial p(x) = a0...

USING C++

1) Write a program that repeatedly evaluates a n-th order polynomial p(x) = a0 + a1*x + a2*x^2 + ... + an*x^n where n <= 10 The program inputs n, ai, and x from the keyboard and then prints out the corresponding value of p to the screen. The program continues to input new values of n, ai, x and evaluates p until a negative value for n is input, at which point the program stops.

2)Write a program that calculates exp(x) using the Taylor series approximation exp_approx = 1 + x + x^2 / 2! + x^3 / 3! + ... where x and error are input from the keyboard and a sufficient number of series terms are used such that abs( exp_approx - exp(x) ) < error. Hint: Use *= in a loop to calculate x^i and i! and print them out to the screen to verify that your loop is correct before calculating the series approximation.

In: Computer Science