Questions
Information security is achieved through a combination of what three entities? Provide at least one example...

Information security is achieved through a combination of what three entities? Provide at least one example of each entity.

In: Computer Science

1)Given a list L1, create a list L2 that contains all but the last element of...

1)Given a list L1, create a list L2 that contains all but the last element of L1 (e.g. if L1 is ["a","z",True], L2 should be equal to ["a","z"]

2)Given a string s, assign a variable has_z that is True if s contains the letter "z" anywhere within it.

3)Write Python code that calculates the mean of a given list of numbers x and saves the result in a variable m.

4)Given two numeric variables, x and y, assign the maximum of x and y to a variable m.

5)given a string s, write Python code that sets a boolean variable has_two_caps to True if the string contains exactly two capital letters (use the .isupper() string method to test individual letters) and False otherwise.

6)Given two variables x and y containing numerical values and a boolean variable use_x, assign a third variable z the value of x if use_x is True; assign it the value of y if use_x is False.

7)Given a list of logical values x, set all_x to True if all of the values in x are True, and False otherwise

IN PYTHON!!

In: Computer Science

I am practicing questions to studying with and the prompt is to: Write statements that assign...

I am practicing questions to studying with and the prompt is to:

Write statements that assign random integers to the variable n in the following ranges:

  1. a) 1 ≤ n ≤ 7
  2. b) 1 ≤ n ≤ 221
  3. c) 0 ≤ n ≤ 49
  4. d) 1000 ≤ n ≤ 1114
  5. e) –2 ≤ n ≤ 9
  6. f) –13 ≤ n ≤ 21

This is what I have thus far but when it displays my fourth value that is supposed to be in between 1000 and 1114 is does not confine between those values, am I doing something wrong/is there a way to simplify my work? Looking for a detailed answer with an explanation to really understand this. This is what I have:

<html>
<head>
<meta charset = "utf-8">
<title>Random integers to variable</title>
<style type = "text/css">
p { margin: 0px; }
p.space { margin-top: 10px; }
</style>
<script>
var value1;
for ( var n = 1; n <= 1; ++n )
{
value1 = Math.floor( 1 + Math.random() * 7);
document.writeln( "<p>" + value1 + "</p>" );
}

var value2;
for ( var n = 1; n <= 1; ++n )
{
value2 = Math.floor( 1 + Math.random() * 221);
document.writeln( "<p>" + value2 + "</p>" );
}

var value3;
for ( var n = 1; n <= 1; ++n )
{
value3 = Math.floor( 0 + Math.random() * 49);
document.writeln( "<p>" + value3 + "</p>" );
}

var value4;
for ( var n = 1; n <= 1; ++n )
{
value4 = Math.floor( 1000 + Math.random() * 1114);
document.writeln( "<p>" + value4 + "</p>" );
}

var value5;
for ( var n = 1; n <= 1; ++n )
{
value5 = Math.floor( -2 + Math.random() * 9);
document.writeln( "<p>" + value5 + "</p>" );
}

var value6;
for ( var n = 1; n <= 1; ++n )
{
value6 = Math.floor( -13 + Math.random() * 21);
document.writeln( "<p>" + value6 + "</p>" );
}

</script>
</head>
<body></body>
</html>

In: Computer Science

home / study / engineering / computer science / computer science questions and answers / Using...

home / study / engineering / computer science / computer science questions and answers / Using JAVA The Following Code Is Able To Read Integers From A File That Is Called "start.ppm" ...

Your question has been answered

Let us know if you got a helpful answer. Rate this answer

Question: Using JAVA The following code is able to read integers from a file that is called "start.ppm" ont...

Using JAVA

The following code is able to read integers from a file that is called "start.ppm" onto a 3d array called "startImage".

Implement the code by being able to read from another file (make up any file name) and save the data onto another 3d array lets say you call that array "finalImage".

The purpose of this will be to add both arrays and then get the average

Save the average onto a separte 3darray,lets say you call it "middlearray"

Then add startImage and middlearray and get the average then save it to another array called "fourtharray"

Then add finalImage and middle array and get the average then save it to another array called "fiftharray".

Print all 5 arrays

I can not submit data file because there are about 667,000 integers on each file and both files are the same size. The file is from an image that got converted onto a ppm file. I don't really see the purpose in adding the file to this question either way. The code below is already capable of reading from one file. I just need to code that will allow me to read from a different file (lets say we call that file "final.ppm". Please write an individual method for each file that is being read. Then add answer the questions from above.

I have already posted this question 2 times and its been answered by the same person and everytime i run the program it just prints only 0's. If this questinon gets answered by the same person again its OK.

import java.util.Scanner;
import java.io.*;

public class P1
{

public static void main(String[] args) throws IOException
{
final int ROW=1000;
final int COL=667;
File file= new File("start.ppm");
Scanner inputF= new Scanner(file);

int[][][] startImage= new int[ROW][COL][3];
  
int row=0, col=0;
int line=1;
while (inputF.hasNext())
{
if(line<=4)
{
inputF.nextLine();
line++;
}
else
{
line+=3;
if (col< COL)
{
startImage[row][col][0]=inputF.nextInt();
startImage[row][col][1]=inputF.nextInt();
startImage[row][col][2]=inputF.nextInt();
col++;
}
else
{
row++;
col=0;
startImage[row][col][0]=inputF.nextInt();
startImage[row][col][1]=inputF.nextInt();
startImage[row][col][2]=inputF.nextInt();
col++;

}
}
  
}
inputF.close();


for(row=0;row {
for(col=0;col {
for(int color=0;color<3;color++)
{
System.out.println(startImage[row][col][color]);

}
}
}

}

}

In: Computer Science

describe the security principle of simplicity.

describe the security principle of simplicity.

In: Computer Science

11. Consider three processes P1, P2, and P3, and all them three are ready to run...

11. Consider three processes P1, P2, and P3, and all them three are ready to run at time = 0. Each process has two CPU bursts. When its first CPU burst is completed, each process requests a blocking I/O operation on a separate I/O device. When a process starts to receive service for I/O, the OS scheduler selects and dispatches another process available at the ready queue. The CPU scheduling policy is preemptive priority-based scheduling, where a process being running can be preempted at the arrival of a higher priority process (think about how a preemptive SJF preempts a job currently being running). A smaller priority value indicates a higher priority. Assume the system has only one CPU core.

Process          Priority           1st CPU burst             I/O burst         2nd CPU burst

P1                   1                      5                                  20                    5         

P2                   2                      5                                  10                    10

P3                   3                      5                                  4                      5

Draw the Gantt chart for the above system (make sure to highlight process preemption and completion); calculate the average turnaround time and average waiting time – show your work.

In: Computer Science

This is my code for an array using the bubblesort in the function outside of main....

This is my code for an array using the bubblesort in the function outside of main. My bubblesort is not working correctly , and I was told i'm missing a +j instead of +i in the function for void sorter.Can someone please help me with making my sorter work properly? everything else is fine and runs great. Thank you

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void printer(int *ptr, int length); 
void randomFill(int *ptr, int length);
void sorter(int *ptr, int length);

int main(void)

{

        int size =30;
        int array[size];
        int *myPointer;
        myPointer = array;
        int i;
        
        
        for(i =0; i<size; i++)
        {
           *myPointer = 0;
           myPointer++;
        }
           
        printf("\nArray before:\n\n");
        printer(array, size);

        
        randomFill(array, size);
        printf("\nArray after insert:\n\n");
        printer(array, size);

        
        sorter(array, size);
        printf("\nArray after sort:\n\n");
        printer(array, size);

        return 0;

}

void printer(int *ptr, int length)

{
        int i =0;
        
        for(i =0; i<length; ++i)
        printf("a[%d] = %d\n\n", i, *(ptr + i));

}

void randomFill(int *ptr, int length)

{
        srand(time(NULL));
        int i;

        for(i =0; i<length; i++)
        {
           *ptr = (rand()% (205-55+1)) + 55; 
           ptr++;
        }

}

void sorter(int *ptr, int length)

{
        int i, j, temp;
        
        for(i =0; i<length; i++)
        {
           for(j = i+1; j<length; j++)
          { 
                if(*(ptr +i) > *(ptr +j))
                {
                   temp = *(ptr + i);
                   *(ptr + i) = *(ptr + j);
                   *(ptr + j) = temp;
                }
           }
        }
}
        

In: Computer Science

What is s after the following? String s = "AbCd"; s.toLowerCase(); Answers: abCd abcd ABCD AbCd

What is s after the following?

String s = "AbCd";
s.toLowerCase();
Answers:
abCd
abcd
ABCD
AbCd

In: Computer Science

Two people play the game of Count 21 by taking turns entering a 1, 2, or...

Two people play the game of Count 21 by taking turns entering a 1, 2, or 3, which
is added to a running total. The player who adds the value that makes the total
reach or exceed 21 loses the game. Create a game of Count 21 in which a player
competes against the computer, and program a strategy that always allows the
computer to win. On any turn, if the player enters a value other than 1, 2, or 3,
force the player to reenter the value. Save the game as
Count21.java

In: Computer Science

Show the decimal integer 79 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively...

Show the decimal integer 79 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively in the given order, separated by comma.

In: Computer Science

where k is a 11-bit integer variable. Show the largest possible range in decimal for k...

where k is a 11-bit integer variable. Show the largest possible range in decimal for k that will not cause any overflow in sign-magnitude, one's complement, two's complement and excess-1023 respectively. Each range should be shown as "[min,max]" (without the quotes). The ranges should be shown in the given order and separated by comma, for example, [-1,2],[3,4],[-5,6],[7,8].

In: Computer Science

A process creates a child then it gives it 2 seconds to start in order for...

A process creates a child then it gives it 2 seconds to start in order for the child to register a handler for the SIGTSTP signal and stay alert for receiving the signal. Then the parent reads a command without options from the user and sends it to the child using a pipe then sends SIGTSTP signal to the child. The parent waits after that for the child to terminate then exits. The child handles the SIGTSTP signal by reading a command from the pipe and execute it using execlp system call. Write a C program to implement that logic using the signal handling system not sigaction.   

In: Computer Science

Langton Ant Program: This assignment will apply Langton's ant a two-dimensional universal turning machine on a...

Langton Ant Program:

This assignment will apply Langton's ant a two-dimensional universal turning machine on a 2 dimensional X by X grid where each grid cell is of the color white or black and the ant can be described as one of eight states ie. cell color and orientation.

Create a X by X square grid of “Cell”s that are either black or white. Begin with the “ant” in the center of the grid ( X must be a odd number/integer). Start the ant in a “up” orientation in the center of the board. Perform N steps where each step has to follow some simple rules:

  1. If the ant is on a white tile turn 90° clockwise, then change the color of the tile & move forward one unit
  2. If the ant is on a black tile turn 90° counterclockwise, change the color of the tile and then move forward one unit.

You are to program the `Cell` class according to the following:

Cell color:

The `Cell` class will store the cell's color as a private member variable named `color` of type `CellColor` where `CellColor` is an enumeration data type defined as:

“enum CellColor {white, black};”

Constructor :

The `Cell` class will be constructed using the default constructor i.e. will not accept any arguments. The constructor will set `color` to `white` upon construction.

Cell Color Mutator

The `Cell` class will contain a public member function called `change_color` to change the `color` member. I.e. if `color` is set to `white`, calling `change_color( )` will change the `color` to `black`. The member function `change_color` will return type `void` and will accept no input parameters.

Cell Color Accessors

The `Cell` class will contain two "getter" functions to access `color`.

1.) Must be named `get_color`, will return type `CellColor`, must return the value of `color`, and must accept no input parameters. `get_color must return the value of `Cell`'s `color` member.

  1. Must be named `get_color_string`, must return type `std::string`, and must accept no input. `get_color_string` must return "1" if `color` is `black` and must return "0" if `color` is `white`.

The template we will be using to declare the “Cell” class

Cell.hpp:

#include

// Declare an enumeration data type to store the Cell's color

enum CellColor {white, black};

// Declare the Cell Class

class Cell {

public:

          // Declare default constructor to initialize color to white

          // Declare member function getter for the color (get_color). Returns CellColor

          // Declare a member to flip the color (change_color)

          // Declare a member to print the string for this color.

          // white = "0", black = "1"

private:

          // Declare the color of this cell (color) as type CellColor

};

#endif

Cell.cpp:

#include "Cell.hpp"

(This is only part 1. of this homework assignment so I only need the code for this part I described and not the grid and ant movement yet)

In: Computer Science

In 200 words or more, Describe the role of due care and due diligence in terms...

In 200 words or more, Describe the role of due care and due diligence in terms of their role in reducing liability exposure.

In: Computer Science

hello!! So this is my CIS assignment, my professor is very hard to understand and he...

hello!! So this is my CIS assignment, my professor is very hard to understand and he expects us to be perfect lol. I have tried to run this problem with a code but as you can see he wants to see that when the program is ran, all of the outcomes are listed all at once, the code that I have does meet the math part when it comes to the answers but as I said it does not show me all of my answers listed if not I have to put all of the inputs. also professor wants to see two different outcomes for example

income balance=-100

he wants to see income=nnnn

number of checks

bank fee=nnnn

in other words he wants to see me putting the income but he wants to see an additional.... (as part of the outcome)

I am really sorry but I have tried to go to tutoring and the time for me does not work......

A bank charges $10 per month plus the following check fees for a commercial checking account: $0.10 each for fewer than 20 checks $0.08 each for 20-39 checks $0.06 each for 40-59 checks $0.04 each for 60 or more checks The bank also charges an extra $15.00 if the balance of the account falls below $400 (before any check fees are applied). Write a program that asks for the beginning balance and the number of check written. Compute and display the bank's service fees for the month. Input Validation: Do not accept a negative value for the number of checks written. If a negative value is given for the beginning balance, display an urgent message indicating the account is overdrawn. The transaction data file: transaction.txtPreview the documentPreview the document Output: Beginning balance: $-100 Number of checks written: 30 Your account is overdrawn! The bank fee this month is $27.40 Beginning balance: $400.00 Number of checks written: -20 Number of checks must be zero or more. Beginning balance: $300.00 Number of checks written: 36 The bank fee this month is $27.88 Beginning balance: $300.00 Number of checks written: 47 The bank fee this month is $27.82 Beginning balance: $350.00 Number of checks written: 5 The bank fee this month is $25.50 Beginning balance: $300.00 Number of checks written: 70 The bank fee this month is $27.80

Reading data from a file

# include <iostream>

# include <iomanip>

# include <fstream>

using namespace std;

std; int main()

{ ifstream input;

input.open("transaction.txt");

while (input>>balance>>check)//while loop

{

//Processing the checks }

}//end while loop

/////////// he also provided with this, to include in the program.

thanks! for the help I really appreciate it

few days ago I got this answer:

//Please like and comment

//code.cpp

# include <iostream>

# include <iomanip>

# include <fstream>

using namespace std;

int computeCharge(int balance)

{

int charge = 10;

if (balance < 400)

{

charge += 15;

}

return charge;

}

float computCheckFee(int numberOfChecks)

{

if (numberOfChecks < 20)

{

return numberOfChecks * 0.10;

}

else if (numberOfChecks >= 20 && numberOfChecks < 40)

{

return numberOfChecks * 0.08;

}

else if (numberOfChecks >= 40 && numberOfChecks < 60)

{

return numberOfChecks * 0.06;

}

else

{

return numberOfChecks * 0.04;

}

}

float computeFee(int balance, int numberOfChecks)

{

return computCheckFee(numberOfChecks) + computeCharge(balance);

}

void getResult(int balance, int checks)

{

if (checks < 0)

{

cout << " Number of checks must be zero or more" <<endl;

}

else if (balance < 0)

{

cout << " Your account is overdrawn! The bank fee this month is $" << computeFee(balance,checks)<< endl;;

}

else

{

cout << " The bank fee this month is $" << computeFee(balance, checks) << endl;

}

}

int main()

{

ifstream input;

input.open("transaction.txt");

int balance = 0, check = 0;

while (input >> balance >> check)//while loop

{

cout << "Beginning balance : $" << balance << " Number of checks written: " << check;

getResult(balance, check);

}//end while loop

return 0;

}

//output

but when I run the program if you take a look at it it has "float computeFee(int balance, int numberOfChecks)" this part seems to be the problem because when I run the problem it says the variables are not declared. pls I need help!

In: Computer Science