Questions
Write a Java program that reads two integers on the keyboard and displays them on the...

Write a Java program that reads two integers on the keyboard and displays them on the screen.

In: Computer Science

There is a body of software that is responsible for making it easy to run programs,...

There is a body of software that is responsible for making it easy to run programs, allowing programs to share memory, enabling programs to interact with devices, and other stuff like that. That body of software is called the __________, as it is in charge of making sure the system operates correctly and efficiently in an easy-to-use manner.

operating system

process

linker

compiler

On a Linux system, which of the following gcc command can be used to compile a C file named aloha.c and generate an executable file named hello.out ?

gcc aloha.c

gcc aloha.c -o hello.out

gcc hello.out

gcc hello.c

gcc -o hello.c hello.out

From the OS point of view, a process is a __________.

C program

running program

assembly code

system call

In: Computer Science

find the summation of the sequence of number 1,2,3...n,where n ranges from 1 to 100.use type...

find the summation of the sequence of number 1,2,3...n,where n ranges from 1 to 100.use type long.Display the results in a tabular format that shows n and the corresponding sum. If this were a product instead of sum, what difficulty might you encounter with the variable that accumulates the product?

In: Computer Science

9. What are the two main registers that syscall utilizes?

9. What are the two main registers that syscall utilizes?

In: Computer Science

Step 1. Set up the network topology with the following devices: 2 1841 router 1 Generic...

Step 1. Set up the network topology with the following devices:

  • 2 1841 router
  • 1 Generic Hub (Hub-PT)
  • 3 Generic End Devices (PC-PT)

Step 2. Click on the router to bring up the Configuration Window.

  • This window has three modes:
    • Physical, Config, and CLI (Physical is the default mode).
  • The Physical mode is used to add modules to a device, such as a WAN Interface Card (WIC).
  • The Config mode is used for basic configuration. Commands are entered in a simple GUI format, with actual equivalent IOS commands shown in the lower part of the window.
  • The CLI mode allows for advanced configuration of the device. This mode requires the user to enter the actual IOS commands just as they would on a live device.

Step 4. Select the WIC-2T module and drag it to Slot 0 on the router. Then drag a WIC Cover to Slot1.

Power the device back on

Step 5. Click on the Network Component Box and select Connections. Then select a Copper Straight-through connection to connect the router to the hub.

  • Click on the hub and choose Port 3. Then click on the router and choose interface FastEthernet 0/0.

Click on the Config mode tab of Router0 to begin configuring the device

  • After the device has finished booting, change the display name of the router to ITCSLab_1. Changing the display name does not affect the configuration. Click in the Hostname field and type ITCSLab_1, then press the TAB key. Note the equivalent IOS command is entered in the lower portion of the window.
  • If the device hangs up in the booting process, save the activity. Then close the application and reopen the file.
  • Click on interface FastEthernet 0/0 and assign the IP address 192.168.1.1, then press the TAB key. Enter the subnet mask 255.255.255.0.

  • Click the Port Status to On to enable the port (no shutdown).
  • Make sure that the existing router is selected (it will be grayed out).

Step 1. In the Main Tool Bar click on the Copy tool.

Click on the Paste tool and the copied device will appear in the work area.

Click on the Network Component Box and select Connections. Then select the Serial DCE connection

Click on the ITCSLAB_1 router and select the Config mode

  • Select interface Serial 0/0/0
  • Configure the interface Serial 0/0/0 with the IP address 192.168.2.1, then press the TAB key and enter the subnet mask 255.255.255.0 on the interface.
  • Set the clock rate to 56000
  • Click the Port Status to On to enable the port (no shutdown).

Step 2. Click on the new router and select the Config mode.

  • Change the Display Name and Hostname to ITCSLAB_2.
  • Configure the interface Serial 0/0/0 with the IP address 192.168.2.2, then press the TAB key and enter the subnet mask 255.255.255.0 on the interface.

Step 1. Click on the ITCSLAB_1 router and select the Config tab. Then click on RIP and add the network address 192.168.1.0 and 192.168.2.0.

Step 2. Click on the ITCSLAB_2 router and select the Config tab. Then click on RIP and add the network address 192.168.2.0.

Step 3. Set the default gateway on the PCs

  • Click on PC0 and select the Config tab. Enter the default gateway address 192.168.1.1.
  • Click on PC1 and select the Config tab. Enter the default gateway address 192.168.1.1.
  • Click on PC2 and select the Config tab. Enter the default gateway address 192.168.1.1.

Task 6.Test the connectivity of the network Step 1. Click on the Simulation mode.

  • Select a Simple PDU and click on PC0 as the source, then click on ITCSLAB_2 as the destination.

Step 2. What is the result?                     

Step 3. What did the activity accomplish?

In: Computer Science

C++ CLion using Namespace std Draw a picture of the array that would be created by...

C++ CLion

using Namespace std

Draw a picture of the array that would be created by the following code


int data[10] = {1, 1};
for( int index = 2; index < 8; ++index )
data[ index ] = data[index – 1] + data[index – 2];

In: Computer Science

Explain how the use of Prepared Statements prevents SQL injection attacks. Please give a commented code...

Explain how the use of Prepared Statements prevents SQL injection attacks.

Please give a commented code example, describing the difference between

data base access with and without the use of Prepared Statements (any

programming language may be used for illustration)

In: Computer Science

Assume we are going to copy a string "hello" from a source pointer src to a...

Assume we are going to copy a string "hello" from a source pointer src to a destination pointer dst.

From the viewpoint of common memory management errors, what is the problem with the following piece of code?

char *src = "hello";
char *dst;
strcpy(dst, src);

No memory space has been allocated for the pointer dst

No memory space has been allocated for the pointer src

The first statement (char *src = "hello";) could cause an error

The strcpy(dst, src) call should be strcpy(src, dst)

From the viewpoint of common memory management errors, what is the problem with the following piece of code?

int *x = (int *)malloc(sizeof(int));
printf("*x = %d\n", *x);

Forgetting to free memory before the malloc() call

Encountering an uninitialized read in the printf() call

No memory space has been allocated for the pointer x

Forgetting to free memory before the printf() call

Address translation transforms each memory access (e.g., an instruction fetch, load, or store), changing the virtual address provided by the instruction to a __________ address where the desired information is actually located.

pseudo

physical

internet

mobile

In: Computer Science

Write a python program that calculates the average number of words per sentence in the input...

Write a python program that calculates the average number of words per sentence in the input text file. every sentence ends with a period (when, in reality, sentences can end with !, ", ?, etc.) and the average number of sentences per paragraph, where a paragraph is any number of sentences followed by a blank line or by the end of the text.

In: Computer Science

Assume there is a 30-byte heap. The free list for this heap has two elements on...

Assume there is a 30-byte heap. The free list for this heap has two elements on it. One entry describes the first 10-byte free segment (bytes 0-9), and one entry describes the other free segment (bytes 20-29).

Now assume we have a request for just a single byte of memory. In this case, the allocator will perform an action known as __________ to find a free chunk of memory that can satisfy the request.

splitting

coalescing

chopping

relocating

Refer to the previous question.

After the action is completed, how many elements are there on the free list?

3

4

2

1

__________ is a strategy for managing free space which results in the smallest leftover hole in memory.

Best fit

Next fit

First fit

Worst fit

__________ is a strategy for managing free space which results in the largest leftover hole in memory.

Next fit

Best fit

Worst fit

First fit

In: Computer Science

When the following statements are executed, what is the output from the child process? You may...

When the following statements are executed, what is the output from the child process? You may assume all variables have been properly declared and all function calls are successful.

var2 = 200;
var3 = 300;
var1 = fork();
if ( var1 > 0 )
{
   printf("%d\n", var2);
}
else
{
   printf("%d\n", var3);
}

200

1

0

300

100

A process that has terminated, but whose parent has not yet called wait(), is known as a __________ process.

zombie

terminated

false

init

In Unix/Linux, a process can run the __________ system call to load another executable to its memory image.

wait()

exit()

fork()

exec()

In: Computer Science

1) The document must have a small image that must appear at the position of the...

1) The document must have a small image that must appear at the position of the mouse cursor when the mouse button is clicked, regardless of the position of the cursor at that time.

2) The document contains four small paragraphs of text, stacked on top of each other, with only enough of each show so that the mouse cursor can always be placed over some part of them. When the cursor is placed over the exposed part of any paragraph, it should rise to the top to become completely visible.

Need help with two JavaScript tasks. Please do them separately and do both of them because they are linked to each other. Also please attach browser images running code. Thankyou.

In: Computer Science

Write a hangman program in c++.The game is played as follows: 1. The program selects a...

Write a hangman program in c++.The game is played as follows:

1. The program selects a random word for the user to guess (Read words for the user to guess into an array of strings from a file. The words are: revolutionary, meaning, recovery, compartment, trainer, pursuit, harm, platform, error, confusion)

2. User guesses one letter at a time until either they guess the word, or they run out of guesses.

3. Select a random word from the array of strings to the word the user has to guess.

Maintain 2 char arrays:

a. availableLetters: a char array of the available letters the user can choose their guess from. Initialize availableLetters as the lowercase alphabet. As the user guesses letters, replace the corresponding guessed letter with a space to denote the letter has already been guessed.

b. visibleLetters: a char array of the not guessed letters in the word. Initialize visibleLetter to all dashes ("-"). As the user correctly guesses a letter, replace the corresponding dash(es) with the correct letter.

4. The main game loop:

a. Display information regarding the status of the game (visibleLetters, availableLetters, and the number of incorrect guesses remaining (the user gets 7 incorrect guesses)).

b. Prompt the user to enter their guess. If the user tries to guess a letter they have already guessed, inform the user and re-prompt.

c. Exit the loop if the users completely guesses the letters of the word or if the user runs out of incorrect guesses.

Note: relevant string methods you will likely need to use for this program are <string variable>.at(i) to get a character at index position and i and <string variable>.size() (or <string variable>.length() to get the number of characters in the string.

Example output:

The word to guess has 5 letters.

----- 
Available letters: abcdefghijklmnopqrstuvwxyz
7 incorrect guesses remaining.
Please enter your guess: 
s
s is not in the word. Too bad. 6 incorrect guesses remaining.

----- 
Available letters: abcdefghijklmnopqr tuvwxyz
6 incorrect guesses remaining.
Please enter your guess: 
e
Nice! e is in the word.

-e---
Available letters: abcd fghijklmnopqr tuvwxyz
6 incorrect guesses remaining.
Please enter your guess: 
r
r is not in the word. Too bad. 5 incorrect guesses remaining.

-e---
Available letters: abcd fghijklmnopq  tuvwxyz
5 incorrect guesses remaining.
Please enter your guess: 
r
r is not an available letter

-e---
Available letters: abcd fghijklmnopq  tuvwxyz
5 incorrect guesses remaining.
Please enter your guess: 
l
Nice! l is in the word.

-ell-
Available letters: abcd fghijk mnopq  tuvwxyz
5 incorrect guesses remaining.
Please enter your guess: 
h
Nice! h is in the word.

hell-
Available letters: abcd fg ijk mnopq  tuvwxyz
5 incorrect guesses remaining.
Please enter your guess: 
o
Nice! o is in the word.
Congrats, you guessed the word hello!

In: Computer Science

• Describe executive, managerial, and associate-level roles in project management??

• Describe executive, managerial, and associate-level roles in project management??

In: Computer Science

How do I get the computerPlayer to play as the other character? This is a connect4...

How do I get the computerPlayer to play as the other character? This is a connect4 game that has to use the the connect4ComputerPlayer to play as the other character when playing connect4 in the text console. How can i achieve this?

Programming language is java.

import java.util.Random;
import ui.Connect4TextConsole;

public class Connect4ComputerPlayer {
   public static void ComputerPlayer(){
       int counter = 1;
       Random rand = new Random();
       int computerMove = rand.nextInt(5) + 1;
       int column = computerMove;
       while(true){
           if(column > Connect4.width){
               System.out.println("Invalid column Input.");
               break;
           }
           if (Connect4.board[Connect4.widthMinus][column] == '|') {
               Connect4.board[Connect4.widthMinus][column] = 'X';
               break;
           }
           else if(Connect4.board[Connect4.widthMinus][column] == 'X' || Connect4.board[Connect4.widthMinus][column] == 'O'){
               if(Connect4.board[Connect4.widthMinus - counter][column] == '|'){
                   Connect4.board[Connect4.widthMinus - counter][column] = 'X';
                   break;
           }
           }
           counter += 1;
           }
       }
}


---------------------------------------------------------------------------------------------------------------------

import java.util.Scanner;
import core.Connect4ComputerPlayer;
import core.Connect4;
public class Connect4TextConsole {
   public static void main(String[] args) {
       Connect4 game = new Connect4();
       boolean go = true; //true player O, false player X
       Scanner keyboard = new Scanner(System.in); //creates a new scanner, used for console input.
       do {
           go = !go;
           game.boardLayout();
           char player;
           if(go) { //alternates who goes with player X going first.
               player = 'O';
           }else {
               player = Connect4ComputerPlayer.ComputerPlayer('X');
           }
           System.out.print("\nPlayer"+player+" - your turn. Choose a column number from 1-7.");
           boolean valid = false;
           while(!valid) {   //Checks if it can place a disk and if not prompts invalid move
                   valid = game.dropDisk(player, keyboard.nextInt());
                   if(!valid) {
                       System.out.print("Invalid move");
                   }          
               }
       } while(!game.draw() & !game.winCondition()); //Checks if game is either a draw or any of the 4 win conditions are met.
       game.boardLayout();
       if(game.winCondition()) {
           System.out.printf("Player %s Won the game", (go?"O":"X")); //prints which player wins the game, depends on the turn that it ended on.
       }
       keyboard.close(); //stop resource leak
   }
}

-----------------------------------------------------------------------------------------------------------

public class Connect4 {
   static char[][] board;
   final static int width = 6;
   final static int height = 7;
   final static int widthMinus = width - 1;
  
   public Connect4() {
       board = new char[width][height];   //42 spots to fill size of board, creates board.
       for(int i=0; i            for(int j=0; j                board[i][j] = ' ';
           }
       }
   }
   /* public char get(int i, int j) {
       return board[i][j];
    } */
   public void boardLayout() { //creates layout for the board and where | go.
       for(int i=0; i            System.out.printf("|");
           for(int j=0; j                System.out.printf("%c|", board[i][j]);
           }
           System.out.println();
       }
   }
    public boolean dropDisk(char player, int verticalWin) { //drops disk or X/O into selected slot
        verticalWin--;
        boolean drop = false;
        for(int i=board.length - 1; i >= 0; i--) {
            if(board[i][verticalWin] == ' ') {
                board[i][verticalWin] = player;
                drop = true;
                break;
            }
        }
        return drop;
   }
   public boolean draw() { //if the game ends in a draw, no more spaces to fill
       for(int i=0; i            if(board[0][i] == ' ') {
               return false;
           }
       }
       return true;
   }
   public boolean winCondition() { //Our method called winCondition that uses boolean values for each time a player may win.
       //if the win condition can be met, if not then continues game. Done so by having them set as false, if one of them turns true then game ends.
       boolean horizontalWin = false;
        boolean verticalWin = false;
        boolean diagonal1Win = false;
        boolean diagonal2Win = false;
        for (int row = 0; row < board.length; row++) { //horizontalWin if four spots are filled with correct character horizontally
            for (int col = 0; col < board[0].length - 3; col++) {
                if (board[row][col] != ' '
                   && board[row][col] == board[row][col + 1]
                   && board[row][col] == board[row][col + 2]
                   && board[row][col] == board[row][col + 3]) {
                    horizontalWin = true;
                }
            }
        }
        for (int col =0; col < board[0].length; col++) { //verticalWin if four spots are filled with correct character vertically
            for (int row = 0; row < board.length - 3; row++) {
                if (board[row][col] != ' '
                   && board[row][col] == board[row + 1][col]
                   && board[row][col] == board[row + 2][col]
                   && board[row][col] == board[row + 3][col]) {
                    verticalWin = true;
                }
            }
        }
        for (int row = 0; row <= 2; row++) { //diagonal1win if four spots are filled with correct character from top right to bottom left
            for (int col = 3; col <= 6; col++) {
                if (board[row][col] != ' '
                   && board[row][col] == board[row + 1][col - 1]
                   && board[row][col] == board[row + 2][col - 2]
                   && board[row][col] == board[row + 3][col - 3]) {
                    diagonal1Win = true;
                }
            }
        }
        for (int row = 0; row <= 2; row++) { //diagonal2win if four spots are filled with correct character from top left to bottom right
            for (int col = 0; col <= 3; col++) {
                if (board[row][col] != ' '
                   && board[row][col] == board[row + 1][col + 1]
                   && board[row][col] == board[row + 2][col + 2]
                   && board[row][col] == board[row + 3][col + 3]) {
                    diagonal2Win = true;
                }
            }
        }
        if (horizontalWin | verticalWin | diagonal1Win | diagonal2Win) //checks if any of them are true, if so then game ends, if not then game continues
            return true;
        else
            return false;
    }
}

----------------------------------------------------------------------------------------------------

In: Computer Science