Write a java program that asks the user for a positive integer N and then calculates a new value for N based on whether it is even or odd: if N is even, the new N is N/2. (Use integer division.) if N is odd, the new N is 3*N + 1. Repeat with each new N until you reach the value 1. For example, say the initial value is 12. Then the successive values are:
12 (even, next value is 12/2)
6 (even, next value is 6/2)
3 (odd, next value is 3*3+1)
10 (even, next value is 10/2)
5 (odd, next value is 3*5+1)
16 (even, next value is 16/2)
8 (even, next value is 8/2)
4 (even, next value is 4/2)
2 (even, next value is 2/2)
1 (stop calculation)
In: Computer Science
The following problems deal with sign extension and overflow. Registers X0 and X1 hold the values as shown in the table below. You will be asked to perform LEGv8 operations on these registers and show the result for the contents of A and B in the table 2 following.
A. |
X0 = 0x7000000016 |
X1 = 0x0FFFFFFF16 |
B. |
X0 = 0x4000000016 |
X1 = 0x4000000016 |
Table 2.
ADD X4, X0, X1
SUB X4, X0, X1
ADD X4, X0, X1
ADD X4, X0, X0
In: Computer Science
Convert the Queue to Generic implementation:
public class MyQueueImpl implements MyQueue {
private int capacity;
private int front;
private int rear;
private int[] arr;
public MyQueueImpl(int capacity){
this.capacity = capacity;
this.front = 0;
this.rear = -1;
this.arr = new
int[this.capacity];
}
@Override
public boolean enQueue(int v) {
if(this.rear ==
this.capacity - 1) {
//Perform shift
int tempSize = this.size();
for(int i=0; i < tempSize; i++) {
arr[i] = arr[front];
front++;
}
front = 0;
rear = tempSize - 1;
}
this.rear
++;
arr[rear] =
v;
return
true;
}
@Override
public int deQueue() {
return arr[front++];
}
public String toString() {
String content = "Queue :: ";
for(int i=front; i<= rear; i++)
{
content += "\n"
+ arr[i];
}
return content;
}
@Override
public boolean isFull() {
return (this.size() ==
this.capacity);
}
@Override
public int size() {
return rear - front + 1;
}
@Override
public boolean isEmpty() {
// TODO Auto-generated method
stub
return (this.size() == 0);
}
@Override
public int peek() {
// TODO Auto-generated method
stub
return this.arr[this.front];
}
}
In: Computer Science
Linux
Have your script request a word from the user, then checks if it is an ordinary file. If yes display the size of the file. If the name is a directory, then display the number of objects in that directory, then display the second line of a long listing of that directory.
In: Computer Science
in assemby, please share code and output - thanks
1. First clear all your general purpose registers by moving the value “0” into them. Initialize a variable for a BYTE, WORD, DWORD storage size each with any desired value in the data segment. Initialize another variable called Result with the size of a DWORD and make the value as an uninitialized value. In the code segment, create a label called L1 that moves the variables in the appropriate sized register and making sure NOT to overwrite them in the process. After, create another label L2 that adds all these values together and at the end of your program make sure your ECX register contains the final value. Call the DUMPREGS instruction to display your register values and move the final result into the Result variable.
2. Use the following code below as a template and follow the instructions written in the comments ;Assume I have the following data segment written: .data val1 BYTE 10h val2 WORD 8000h val3 DWORD 0FFFFh val4 WORD 7FFFh ;1. Write an instruction that increments val2. ;2. Write an instruction that subtracts val3 from EAX. ;3. Write instructions that subtract val4 from val2. .code ;Write your instructions here
In: Computer Science
Compare radixSort to bubbleSort, SelectionSort, and InsertionSort
Compare quickSort to bubbleSort, SelectionSort, and InsertionSort
In: Computer Science
what is the operation for DragonFly BSD
DragonFly BSD os structure
In: Computer Science
Write a function lbs2lboz(p) that takes a non-negative number, p , that represents a weight in pounds and outputs a pair (l,o) such that l is an integer and p=l+o/16.
Write a function oz2lboz(oz) that takes a non-negative number, oz , that represents a weight in ounces and outputs a pair (l,o) such that l is an integer and oz=l*16+o.
on python
In: Computer Science
What are the three types of processor scheduling?
What is the difference between turnaround time and response time?
What is the difference between preemptive and non-preemptive scheduling?
Is a non-preemptive scheduling approach a good choice for interactive systems? Why?
What is the meaning of the term: feedback scheduling?
In: Computer Science
IN JAVA
Methods**: Sort three values
Write a method Ascend3 with an array of integers of size three as the parameter, that sorts the values of the array into ascending order. Ex: If the array contains [5, 2, 7], after the call Ascend3(int[] vals), the array will now hold [2, 5, 7].
Hints:
Return type should be void.
One approach puts the three values into an array, then sorts the array. We won't be describing that approach here. Instead, we'll use branches.
One solution approach realizes that only 6 possible orderings of xyz exist: xyz, xzy, yxz, yzx, zxy, zyx. An if-else can be used to detect which order x, y, z are initially in.
Once detected, three variables lowVal, midVal, and highVal can be assigned. Note: Don't assign the parameter right away, because you'll overwrite a value that is still needed.
After the if-else, those lowVal, midVal, and highVal variables are ready. So just set the vals[0] with lowVal, vals[1] with midVal, and vals[2] with highVal.
Be aware that two values could be equal. So use <= rather than < in your comparisons.
GIVEN CODE:
import java.util.Scanner;
public class Main {
// Define Ascend3() here
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int[] arrVals = new int[3];
arrVals[0] = scnr.nextInt(); // x
arrVals[1] = scnr.nextInt(); // y
arrVals[2] = scnr.nextInt(); // z
Ascend3(arrVals);
System.out.println(arrVals[0] + " " + arrVals[1] + " " +
arrVals[2]);
}
}
In: Computer Science
Implement the earse one() function by using the array shifting method (i.e., remove one target item and shift all right items one position left).
In: Computer Science
How does a value-returning function differ from the void functions? in pyhton
In: Computer Science
In: Computer Science
Please re-write paragraphs.
-In the following slides I will be discussing the three different methods that are for determining the requirements for gathering information. I will discuss the advantages and disadvantages of each method, along with explaining the Level-0 Data Flow Diagram, the last thing I will be discussing is the method in which I chose for determining the requirements for the student furniture webstore that the Pine Valley Furniture store decided to plan and implement first.
- The above slide has the three different methodologies listed that are used for requirements gathering. They are the traditional, contemporary, and radical methodologies. I am going to discuss what’s involved in each methodology along with what are the advantages and disadvantages of each methodology.
- The traditional method of doing things is the old way of doing things in which many organizations still use today. I think this method should still be used to some extent because I feel you still get good solid information and feedback from your users. In the traditional way the organization can interview people to see what the ”issues and operation of the current system” and the system coming. (Valacich & George, 2020, p. 148) Traditionally you would interview a lot of different people that have different “needs to find synergies and contrasts among system requirements “(Valacich & George, 2020, p. 148) One of my favorite traditional methods are sitting in on workers as during their daily routine and seeing how they perform their daily tasks and what other tools they need to accomplish them. One last traditional method is to go over old “business documents” so that the organization can see “issues, policies, rules, and directions”. The traditional method also has (examples that are solid that show the use of the organizations data and information). The advantages of traditional methodology are you will get more (solid and correct information from your users when you observe them during their daily work tasks, when the documentation and procedures are analyzed they will give information about the organization as well as identifying the current system requirements, it allows the analyst to work with having the procedures and documentation in front of them to refer back to, the documentation will list everyone who is involved in the current system.)The disadvantages of directly observing employees are that it can be (costly and take up too much time, procedures come up missing, users are repeating what’s already been done, the procedures and documents being analyzed may need to be updated along with they may be hard to find, and one last disadvantage is that the documents and procedures may say one thing about operation but the organization operates in an entirely whole different way.
- The contemporary method is similar to the traditional method. In the contemporary method is where “managers, analysts, users, and other members” that are needed are brought together in a JAD which is a Joint Application Design that is an arraigned process where “very intense meetings” take place to identify and go over the “systems requirements.” (Valacich & George, 2020, p. 159-160) The other thing that happens during use of a contemporary method are (prototypes are developed for the system that clearly define the system requirements are understood in solid terms by showing working versions of system features.) (Valacich & George, 2020) The advantages of the contemporary methodology are in using the Joint Application Design it will allow the users to effectively take place in the process, the organization will have a more solid and precise statement of the systems requirements, and everyone will have a better comprehension of the organizations goals.) ("Prezi", 2020). Some other advantages of the contemporary methodology are in using prototyping because this is where at the (beginning stages of the development prototyping lets the identification of the potential risks involved and to rectify the errors, also when the “developers and testers” are making the prototype they can very easily make it to accommodate what the customer wants and needs with being able to make adjustments when necessary, as well as when showing it to the customer this is the perfect way to do so, and when using prototyping the “developers have a great chance of getting much wanted “valuable feedback” from the users so this will save them a great deal of time, effort, and money down the road. According to "Velvetech"(2020), The disadvantages of using the contemporary method are in using the (JAD) Joint Application Design is the more expensive way to go because there are many more people involved and there is not enough resources available.) ("Prezi", 2020). The disadvantages of using prototypes are that “the initial result of a prototype is never the market-ready product”, (making changes all the time will make so there are many designs and changes within the code, and this will slow down the flow in which the employees are doing their tasks), ("Velvetech", 2020) and sometimes “software vendor that covers for the cost of a prototype.” According to "Velvetech"(2020),
In: Computer Science
1.
(A) A Web server is identified by port number 25 while an email server process using the SMTP protocol is identified by port number 80.
True
False
(b) Both SMTP with HTTP are used to transfer files from one host to another.
True
False
(c) We are sending a 30 Mbit MP3 file from a source host to a destination host. All links in the path between source and destination have a transmission rate of 10 Mbps. Assume that the propagation speed is 2*108 meters/sec, and the distance between source and destination is 10,000 km. Now suppose there is only one link between source and destination. Also suppose that the entire MP3 file is sent as one packet. How many bits will the source have transmitted when the first bit arrives at the destination?
A. |
30,000,000 bits |
|
B. |
1 bit |
|
C. |
500,000 bits |
|
D. |
none of the above |
(d) Suppose a client sends an HTTP request message with the "If-modified-since": header. Suppose the object in a server has not changed since the last time a client retrieved the object. Then the server will send a response message with the status code ____.
A. |
200 OK |
|
B. |
404 Not Found |
|
C. |
304 Not Modified |
|
D. |
none of the above |
(e) UDP provides a flow-control service to its applications to eliminate the possibility of the sender overflowing the receiver’s buffer.
True
False
(F)The TCP connection is not an end-to-end TDM or FDM circuit as in a packet-switched network.
True
False
In: Computer Science