Questions
Note: The answers to the following questions should be typed in the block of comments in...

Note: The answers to the following questions should be typed in the block of comments in the Assignemnt2.java file. Please make sure they're commented out (green). Type them neatly and make them easy to read for the graders.

Given the String object called myString with the value "Practice makes perfect!" answer the following questions.

Question #1 (1pt): Write a statement that will output (System.out) the number of characters in the string.
Question #2 (1pt): Write a statement that output the index of the character ‘m’.
Question #3 (1 pt): Write a statement that outputs the sentence in uppercase letters

Question #4 (1 pt): Write a statement that uses the original string to extract the new string "perfect" and prints it to the screen
Question # 5 (2 pts): What do the following expressions evaluate to in Java given int x = 3, y = 6;

a) x==y/2
b) x%2==0||y%2!=0 c) x–y<0&&!(x>=y) d) x+6!=y||x/y<=0

Question # 6 (1 pt): What does the following statement sequence print? (page 63)

String str = “Harry”;
int n = str.length();
String mystery = str.substring(0,1) + str.substring(n-1, n);
System.out.println(mystery);

In: Computer Science

Python Describe the procedure for setting up the display of an image in a window.

Python

Describe the procedure for setting up the display of an image in a window.

In: Computer Science

Given an array of positive integers a, your task is to calculate the sum of every...

Given an array of positive integers a, your task is to calculate the sum of every possible a[i] ∘a[j], where a[i]∘a[j] is the concatenation of the string representations of a[i] and a[j] respectively.

Example

  • For a = [10, 2], the output should be concatenationsSum(a) = 1344.
    • a[0] ∘a[0] = 10 ∘10 = 1010,
    • a[0] ∘a[1] = 10 ∘2 = 102,
    • a[1] ∘a[0] = 2 ∘10 = 210,
    • a[1] ∘a[1] = 2 ∘2 = 22.

So the sum is equal to 1010 + 102 + 210 + 22 = 1344.

  • For a = [8], the output should be concatenationsSum(a) = 88.

There is only one number in a, and a[0] ∘a[0] = 8 ∘8 = 88, so the answer is 88.

Input/Output

  • [execution time limit] 3 seconds (java)
  • [input] array.integer a

A non-empty array of positive integers.

Guaranteed constraints:
1 ≤ a.length ≤ 105,
1 ≤ a[i] ≤ 106.

  • [output] integer64
    • The sum of all a[i] ∘a[j]s. It's guaranteed that the answer is less than 253.

[Java] Syntax Tips

In: Computer Science

Increase all of the listing prices by 5% for all listings under $500,000 and 10% for...

Increase all of the listing prices by 5% for all listings under $500,000 and 10% for all listings $500,000 and higher. Update the listings table with the new prices.

update LISTING
set LISTING_PRICE = LISTING_PRICE +
case
  when LISTING_PRICE < 500000 then (LISTING_PRICE*5)/100
  when LISTING_PRICE >= 500000 then (LISTING_PRICE*10)/100
  else 0
end

-- Add 30 days to the date expires for all listings.

update LISTING set DATE_EXPIRES = DATEADD(dd, 30, DATE_EXPIRES)

-- Add "Listing updated on [current date]." to the remarks. Replace [current date] with the current systems date. Do not replace the remarks currently in the table. Add these remarks to the remarks already in the table.

update LISTING set REMARKS=CONCAT(REMARKS ," ","Listing updated on ",GETDATE())

-- Return the following information from the listings table from the stored procedure to display the information in the new real estate app: address, city, state, zip, updated listing price, updated date expires, and updated remarks.

CREATE PROCEDURE DISPLAYLISTING
AS
BEGIN
select ADDRESS,CITY,STATE,ZIP,LISTING_PRICE,DATE_EXPIRES,REMARKS from LISTING;
END;

-- Call and run the stored procedure to make the appropriate updates and return the proper results.

In order to execute the stored procedures we use the following SQL script :

EXEC DISPLAYLISTING;

We can update and display the information from the listings table using following stored procedure as :

CREATE PROCEDURE DISPLAYLISTING
AS
BEGIN

update LISTING
set LISTING_PRICE = LISTING_PRICE +
case
  when LISTING_PRICE < 500000 then (LISTING_PRICE*5)/100
  when LISTING_PRICE >= 500000 then (LISTING_PRICE*10)/100
  else 0
end;

update LISTING set DATE_EXPIRES = DATEADD(dd, 30, DATE_EXPIRES);
  
update LISTING set REMARKS=CONCAT(REMARKS ," ","Listing updated on ",GETDATE());

select ADDRESS,CITY,STATE,ZIP,LISTING_PRICE,DATE_EXPIRES,REMARKS from LISTING;

END;

For this lab exercise you will be working with and modifying the stored procedure you created in the last module. In your stored procedure, the first three requirements performed updates to your database and the last two requirements returned the data that was updated. Perform the following:

1. Enclose the code for the first requirement in its own single transaction with the proper commit and rollback functions.

2. Enclose the code for both the second and third requirements in one single transaction with the proper commit and rollback functions.

3. Call and run the stored procedure to make the appropriate updates and return the proper results. Take the appropriate screenshots to show this working and insert into your screenshot document.

4. In the second transaction you created that included the code for the second and third requirements - create an error in the middle of the transaction between the code for the two requirements. For example, you can add an insert or an update statement that uses a field that does not exist. This would cause an error. When you run it, the error should cause the entire transaction to rollback. Because of this error, no changes should be made by this transaction. This is one way of testing your rollback code.

5. Call and run the stored procedure a second time to make the appropriate updates and return the proper results. The first transaction should run without any issues but the second transaction should rollback any changes it made.

You are going to take the stored procedure you created in the lab exercise from the last module and create two transactions within it. The first transaction will contain the first requirement from that module's lab exercise. The second transaction will contain the second and third requirements from that module's lab exercise. You will run it and take screenshots to show it working properly. Then you will purposely insert code to create an error in the middle of the second transaction, in between the two items to cause the transaction to fail and rollback any changes. You will run it again and take screenshots to show your rollback working properly.

In: Computer Science

Use fork() Create a program that reads characters from an input file. Use fork to create...

Use fork()

Create a program that reads characters from an input file. Use fork to create parent and child processes.

The parent process reads the input file. The input file only has letters, numbers. The parent process calculates and prints the frequency of the symbols in the message, creates the child processes, then prints the information once the child processes complete their execution.

The child processes receives the information from the parent, generates the code of the assigned symbol by the parent, and saves the generated code into a file.

Example:

Input.txt: aaaannnaaakkllaaaaap

Output.txt:

a frequency = 12

n frequency = 3

k frequency = 2

l frequency = 2

p frequency = 1

Original Message: aaaannnaaakkllaaaaap

In: Computer Science

A sample human input file that contains test values that a human would enter on the...

A sample human input file that contains test values that a human would enter on the keyboard (covering both normal cases and boundary/error cases)

My code is to search the puzzle, read human_input.txt and then search the word

I have a problem with this line : while(fgets(humanchar, 1000, humanfile)),

searchfirst(array,height,width,"happy"); is search well but searchfirst(array,height,width,humanchar); is nothing happen

In addition, The input may contain upper and lower case characters, I try to convert it to lowercase, but i have a problem, so help me with it "you should convert them all to lower case when you read them."

And finally help me to reverse the word in each search

human_input.txt

search_puzzle.txt
happy
error
hope
exit

searchpuzzle.txt

10 7
ABCDEFt
SsGKLaN
OPpRcJW
PLDrJWO
ELKJiIJ
SLeOJnL
happyTg
BEoREEa
JFhSwen
ALSOEId

test.c

#include <stdio.h>
#include "functions.h"
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

int fileio()
{   FILE *humanfile;
    char humanchar[1000];
   FILE *ptr_file;
   char buf[1000];
   int height,width;
   char **array; //create double pointer array
   // open human_input file
   humanfile = fopen("human_input.txt", "r");
       if (!humanfile)
       {
            printf("File is not available \n");
       return 1;
       }
   char filename[10];
   // get a name of puzzle file
   fscanf(humanfile,"%s",filename);
   //open puzzle file
   ptr_file =fopen(filename,"r");
   if (!ptr_file){
       printf("File is not available \n");
       return 1;
   }
   fscanf(ptr_file,"%d %d",&height,&width); // get height and weight
   printf("%d ",height);
   printf("%d",width);
   printf("\n");
   //allocate array
   array = (char **)malloc(sizeof(char *)*height); // create the array size
   for(int i = 0; i<height;i++){
       array[i] = (char *)malloc(sizeof (char) * width);
   }  
  
   int col = 0, row;
   //get a single char into array
   for(row=0; row<height; row++){
       fscanf(ptr_file, "%s", buf);
       for (int i =0; i <= width;i++){
           if (buf[i] != '\0'){
               array[row][col] = buf[i];
               col++;
       }
       }
       col = 0;
   }

   // print array
   for (int i = 0; i < height; i++) {
       for (int j = 0; j < width; j++){
           printf("%c", array[i][j]);
       }
       printf("\n");
   }
       //close file

   //////////////////////test/////////////////////////////////////////
   //   searchfirst(array,height,width,"happy"); // find the letter
   //   searchfirst(array,height,width,"EId"); // find the letter
       //searchfirst(array,height,width,"tNW");
       //searchfirst(array,height,width,"RwI");
       //searchfirst(array,height,width,"Eed");
       //searchfirst(array,height,width,"PDJ");
      
       //searchfirst(array,height,width,"Ryn");
       //searchfirst(array,height,width,"OsC");
       //searchfirst(array,height,width,"Eea");
       //searchfirst(array,height,width,"LhRynJ");
   /////////////////////////////////////////////////////////////////////
  
   //get a single char into array
  
   // human input I have problem with this one
   while(fgets(humanchar, 1000, humanfile)) {
        // printf("%s\n", humanchar);
           searchfirst(array,height,width,humanchar);
   }
      

       free(array);
       fclose(humanfile);
       fclose(ptr_file);
   return 0;
}

void searchfirst(char **array,int height,int width,char str[]){
// go through array
   for (int i = 0; i < height; i++) {
       for (int j = 0; j < width; j++){
           if (array[i][j] == str[0]){ /// find the first letter in string
           //printf("\nfound %s\n",str);  
           findwordhorizontal(array,i,j,str); //find the word horizontal
           findwordvertical(array,i,j,height,str); // find the word vertical
           findworddiagonal1(array,i,j,height,width,str);
           findworddiagonal2(array,i,j,width,str);
       }  
       }  
   }
}

void findwordhorizontal(char **array,int m,int n,char str[]){

   char *buffer = (char *) malloc(sizeof(char)*(n));  
   int j = 0;
   while (str[j] != '\0'){
       buffer[j] = array[m][n+j]; // add string to buffer
       j++;
   }
   buffer[j] = '\0';//add \0 to ending of string buffer
   int result = strcmp (buffer,str); // comparing string
   if (result==0) // if 2 string equal
   {
       printf("Found the word horizontal %s\n", buffer);      
   }
   free(buffer);
  
}

void findwordvertical(char **array,int n,int m,int height,char str[]){

   char *buffer = (char *) malloc(sizeof(char)*(height ));  
   int j = 0;
   while (n<height){
       buffer[j] = array[n][m]; // add string to buffer
       buffer[j+1] = '\0';//add \0 to ending of string buffer
       int result = strcmp (buffer,str); // comparing string
       if (result==0) // if 2 string equal
       {
           printf("Found the word vertical %s\n", buffer);      
       }
       n++;
       j++;
  
   }
   free(buffer);
}

void findworddiagonal1(char **array,int n,int m,int height,int width,char str[]){
   int count;
   for (count = 0; str[count]; count++){
       // just count length of str
   }  
  
   int calculate1 = width - m; // width - current col
   int calculate2 = height -n; // height - current row
  
   if ( calculate1 >= count && calculate2 >= count){ // if current n m have enough length of str: start searching
       char *buffer = (char *) malloc(sizeof(char)*(calculate1));  
       int j = 0;
       while (j<count){
           buffer[j] = array[n][m]; // add string to buffer
           buffer[j+1] = '\0';//add \0 to ending of string buffer
           //printf("%s vs %s\n",buffer,str);
           int result = strcmp (buffer,str); // compa4 7ring string
           if (result==0) // if 2 string equal
           {
               printf("Found the word diagonal 1 %s\n", buffer);      
           }
           n++;
           m++;
           j++;  
   }
   }
  
}

void findworddiagonal2(char **array,int n,int m,int width,char str[]){
   int count;
   for (count = 0; str[count]; count++){
       // just count length of str
   }  
  
   int calculate1 = width - m; // width - current col
   int calculate2 = n+1; // height - current row
   //printf("%d %d %d\n",calculate1,calculate2,count);
   if ( calculate1 >= count && calculate2 >= count){ // if current n m have enough length of str: start searching
       char *buffer = (char *) malloc(sizeof(char)*(calculate1));  
       int j = 0;
       while (j<count){
           buffer[j] = array[n][m]; // add string to buffer
           buffer[j+1] = '\0';//add \0 to ending of string buffer
           //printf("%s vs %s\n",buffer,str);
           int result = strcmp (buffer,str); // comparing string
           if (result==0) // if 2 string equal
           {
               printf("Found the word diagonal 2 %s\n", buffer);      
           }
           n--;
           m++;
           j++;  
   }
   }
  
}
int main()
{
   fileio();
   return 0;
}

In: Computer Science

Design and inplement a synchronous counter that counts.

Design and inplement a synchronous counter that counts.

In: Computer Science

Q. Compare and contrast Ripple-Carry Adder and Carry-Look ahead Adder 1) In a 4-bit ripple-carry adder...

Q. Compare and contrast Ripple-Carry Adder and Carry-Look ahead Adder

1) In a 4-bit ripple-carry adder as shown in Figure 5.2, assume that each full-adder is implemented using the design as shown in Figure 3.11 (a) and each single logic gate (e.g., AND, OR, XOR, etc.) has a propagation delay of 10 ns. What is the earliest time this 4-bit ripple-carry adder can be sure of having a valid summation output? Explain how you reached your answer and how you did your calculations.

In: Computer Science

1. How are a buffer and a NOT gate similar? 2. How are a buffer and...

1. How are a buffer and a NOT gate similar?

2. How are a buffer and a NOT gate different?

3. When interfacing an Arduino output to a higher voltage, explain how a buffer could be used.

4. What diagram do we use to code the AND function?

5. What diagram do we use to code the OR function?

6. Draw the international diagram for an AND gate.

7. Draw the international diagram for an OR gate.

8. Draw, the truth table for a 3 input AND gate, including the output.

9. Draw the truth table for a 3 input OR gate, including the output.

10. When does 1 + 1 = 1?

In: Computer Science

Cybersecuirty Describe the different types of firewalls that are on the market and how they differ...

Cybersecuirty

Describe the different types of firewalls that are on the market and how they differ from one another. Please write one paragraph fully explaining.

In: Computer Science

Submission Guidelines This assignment may be submitted for full credit until Friday, October 4th at 11:59pm....

Submission Guidelines

This assignment may be submitted for full credit until Friday, October 4th at 11:59pm. Late submissions will be accepted for one week past the regular submission deadline but will receive a 20pt penalty. Submit your work as a single HTML file. It is strongly recommended to submit your assignment early, in case problems arise with the submission process.

Assignment

For this assignment, you will write a timer application in HTML and JavaScript.

Your HTML document should contain the following elements/features:

  1. HTML tags:
    1. An <input> tag labeled "Timer Duration" with the initial value 0
    2. A <button> tag labeled "Start"
  2. Script: When the user presses the button (1b), a function will begin that does the following:
    1. Reads the value from the input field (1a)
    2. Removes the <input> and <button> tags (1a & 1b)
    3. Creates a new <p> tag, initialized to show the input value
    4. Starts a timer that ticks down to zero. For every second that elapses, the paragraph tag (2c) will show the updated timer value (i.e., one less)
    5. When the timer reaches zero, the countdown will stop and the paragraph tag (2c) will be removed and be replaced by a <button> tag labeled "New Timer"
    6. When the <button> tag (2e) is pressed, it will be removed and the <input> and <button> tags (1a, 1b) will be recreated with their original formats

Evaluation

Your assignment will be graded according to whether all the required elements are present and in the correct formats and all required functionalities are operable.

In: Computer Science

Need to program a maze traversal program using dynamic array and stacks. The problem is faced...

Need to program a maze traversal program using dynamic array and stacks. The problem is faced in setting up the data structure and due the problem in setting the data structure other functions like moving in all direction, marking the current cell that is visited are showing the error.

The work so far is below:

const int R = 5; //Number of rows
const int C = 5; //Number of columns

class coordinate
{
public:
int v;
int h;
};

class stack
{
public:
coordinate x;
coordinate y;
};

The maze looks like:

# # S _ #

_ _ _ # #

_ # # _ #

_ _ # # #

_ _ _ _ G

where S = starting point, G = end point, _ = space for moving around and # = wall

In: Computer Science

Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow...

Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example output for userNum = 40:

20 10 5 2 1

In java

import java.util.Scanner;

public class DivideByTwoLoop {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
int userNum;

userNum = scnr.nextInt();

*insert code*

System.out.println("");
}
}

In: Computer Science

Question 1 Discuss the key functions of an operating system, and how these functions make it...

Question 1

Discuss the key functions of an operating system, and how these functions make it possible for computer applications to effectively utilize computer system resources.

Compare and contrast the Windows API and the POSIX API and briefly explain how these APIs can be applied in systems programming.

Write a C/C++ program to create a file in a specified folder of the Windows file system, and write some text to the file. Compile and run the program and copy the source code into your answer booklet.

In: Computer Science

PLEASE MODIFY CODE IN JAVA In-line comments denote your changes and briefly describe the functionality of...

PLEASE MODIFY CODE IN JAVA
In-line comments denote your changes and briefly describe the functionality of each method or element of the class
Appropriate variable and method naming conventions are used throughout your code.
modify the Driver.java class file to do the following:
Implement the method you have chosen
Add attributes, as needed, to support the required functionality
SYSTEM REQUIREMENTS-

Each dog goes through a six- to nine month training regimen before they are put into service. Part of our process is to record and track several data points about the rescue animals.

Dogs are given the status of "intake" before training starts. Once in training, they move through a set of five rigorous phases: Phase I, Phase II, Phase III, Phase IV, and Phase V. While in training, a dog is given the status of its current training phase (e.g., "Phase I"). When a dog graduates from training, it is given the status of "in service" and is eligible for use by clients. If a dog does not successfully make it through training, it is given the status of "farm," indicating that it will live a life of leisure on a Grazioso Salvare farm.

The Animals Through years of experience, we have narrowed the list of dog breeds eligible for rescue training to the following:

• American pit bull terrier

• Beagle

• Belgian Malinois

• Border collie •

Bloodhound

• Coonhound

• English springer spaniel

• German shepherd

• German shorthaired pointer

• Golden retriever

• Labrador retriever

• Nova Scotia duck tolling retriever

• Rough collie

• Smooth collie

When we acquire a dog, we record the breed, gender, age, weight, date, and the location where we obtained them. There is usually a short lag time between when we acquire a dog and when they start training, which we document as well. Additionally, we track graduation dates, dates dogs are placed into "service," and details about the dogs' in-service placement (agency, city, country, and name, email address, phone number, and mailing address for the agency's point of contact).

DRIVER JAVA CODE

public class Driver {

public static void main(String[] args) {

// Class variables

// Create New Dog

// Method to process request for a rescue animal

// Method(s) to update information on existing animals

// Method to display matrix of aninmals based on location and status/training phase

// Method to add animals

// Method to out process animals for the farm or in-service placement

// Method to display in-service animals

// Process reports from in-service agencies reporting death/retirement

}

}


im not sure what store in databse or files means. just follow the //comments on what to put

In: Computer Science