The function below takes a single string parameter: sentence. Complete the function to return everything but the middle 10 characters of the string. You can assume that the parameter always has at least twelve characters and is always an even number of characters long. Hint: To find the middle of the string, you can half the length of the string (floor division). Then slice out 5 less than the middle to 5 more than the middle.

Answers

Answer 1

Answer:

def get_middle_ten(sentence):

   ind = (len(sentence) - 12) // 2

   return sentence[ind:ind + 12]

# Testing the function here. ignore/remove the code below if not required

print(get_middle_twelve("abcdefghijkl"))

print(get_middle_twelve("abcdefghijklmnopqr"))

print(get_middle_twelve("abcdefghijklmnopqrst"))


Related Questions

Create_3D(H,W,D) Description: It creates a list of list of list of ints (i.e. a 3D matrix) with dimensions HxWxD. The value of each item is the sum of its three indexes. Parameters: H (int) is the height, W (int) is the widht, D (int) is the depth Return value: list of list of list of int Example: create_3D(2,3,4) → [[[0,1,2],[1,2,3]], [[1,2,3],[2,3,4]], [[2,3,4],[3,4,5]], [[3,4,5],[4,5,6]]] copy_3D(xs) Description: It creates a deep copy of a 3D matrix xs. Make sure the copy you make is not an alias or a shallow copy. Parameters: xs (list of list of list of int)

Answers

Answer:

See explaination for the details.

Explanation:

Code:

def create_3D(H, W, D):

result = []

for i in range(D):

result.append([])

for j in range(H):

result[i].append([])

for k in range(W):

result[i][j].append(i+j+k)

return result

print(create_3D(2, 3, 4))

Check attachment for onscreen code.

Implement the RC4 stream cipher in C . User should be able to enter any key that is 5 bytes to 32 bytes long. Be sure to discard the first 3072 bytes of the pseudo random numbers. THE KEY OR THE INPUT TEXT MUST NOT BE HARD CODED IN THE PROGRAM.

Answers

RC4 stream cipher in C. User is able to enter any key that is 5 bytes to 32 bytes long

Explanation:

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#define N 256   // 2^8

void swap(unsigned char *a, unsigned char *b) {

   int tmp = *a;

   *a = *b;

   *b = tmp;

}

int KSA(char *key, unsigned char *S) {

   int len = strlen(key);

   int j = 0;

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

       S[i] = i;

   for(int i = 0; i < N; i++) {

       j = (j + S[i] + key[i % len]) % N;

       swap(&S[i], &S[j]);

   }

   return 0;

}

int PRGA(unsigned char *S, char *plaintext, unsigned char *ciphertext) {

   int i = 0;

   int j = 0;

   for(size_t n = 0, len = strlen(plaintext); n < len; n++) {

       i = (i + 1) % N;

       j = (j + S[i]) % N;

       swap(&S[i], &S[j]);

       int rnd = S[(S[i] + S[j]) % N];

       ciphertext[n] = rnd ^ plaintext[n];

   }

   return 0;

}

int RC4(char *key, char *plaintext, unsigned char *ciphertext) {

   unsigned char S[N];

   KSA(key, S);

   PRGA(S, plaintext, ciphertext);

   return 0;

}

int main(int argc, char *argv[]) {

   if(argc < 3) {

       printf("Usage: %s <key> <plaintext>", argv[0]);

       return -1;

   }

   unsigned char *ciphertext = malloc(sizeof(int) * strlen(argv[2]));

   RC4(argv[1], argv[2], ciphertext);

   for(size_t i = 0, len = strlen(argv[2]); i < len; i++)

       printf("%02hhX", ciphertext[i]);

   return 0;

}

If you have downloaded this book’s source code from the companion Web site, you will find a file named Random.txt in the Chapter 05 folder. (The companion Web site is at www.pearsonhighered/gaddis.) This file contains a long list of random numbers. Copy the file to your hard drive and then write a program that opens the file, reads all the numbers from the file, and calculates the following: A) The number of numbers in the file B) The sum of all the numbers in the file (a running total) C) The average of all the numbers in the file The program should display the number of numbers found in the file, the sum of the numbers, and the average of the numbers. Prompts And Output Labels: Print each of the above quantities on a line by itself, preceding by the following (respective) labels: "Number of numbers: ", "Sum of the numbers: ", and "Average of the numbers: ".

Answers

Answer:

Check the explanation

Explanation:

Here is the code for you:

#include <iostream>

#include <fstream>

using namespace std;

int main ()

{

int aNumber=0;

int numbers=0;

double sum=0.0;

double average=0.0;

ifstream randomFile;

randomFile.open("Random.txt");

if (randomFile.fail())

cout << "failed to read file.";

else

{

while (randomFile >> aNumber)

{

numbers++;

sum+=aNumber;

}

if (numbers>0)

average = sum/numbers;

else

average=0.0;

cout << "Number of numbers: " << numbers << "\n";

cout << "Sum of the numbers: " << sum << "\n";

cout << "Average of the numbers: " << average;

}

randomFile.close();

return 0;

}

In this exercise we have to use the computer language knowledge in C++ to write the code as:

the code is in the attached image.

In a more easy way we have that the code will be:

#include <iostream>

#include <fstream>

using namespace std;

int main ()

{

int aNumber=0;

int numbers=0;

double sum=0.0;

double average=0.0;

ifstream randomFile;

randomFile.open("Random.txt");

if (randomFile.fail())

cout << "failed to read file.";

else

{

while (randomFile >> aNumber)

{

numbers++;

sum+=aNumber;

}

if (numbers>0)

average = sum/numbers;

else

average=0.0;

cout << "Number of numbers: " << numbers << "\n";

cout << "Sum of the numbers: " << sum << "\n";

cout << "Average of the numbers: " << average;

}

randomFile.close();

return 0;

}

See more about C++ code at brainly.com/question/25870717

Java Programming-

Goals

The lab this lesson introduces students to Object Oriented Thinking. By the end of this lab, students should be able to

To apply class abstraction to develop software

To discover the relationships between classes

To design programs using the object-oriented paradigm

To use the String class to process immutable strings

Question- Sophie and Sally are learning about money. Every once in a while, their parents will give them penny or shilling coins (no pounds at their age!). They each keep their money in a special purse, and their parents may ask them how many pence or shillings coins they have. (Note we're not interested in the monetary values, just the number of coins. Thus someone might have 25 shilling coins or 20 penny coins.) The interaction between the girls' parents and Sophie and Sally is similar to the following:

Enter 1 for Sophie, 2 for Sally, or 0 to exit: 1
Enter 1 to give pence, 2 to give shillings, 3 to query her purse: 1
Enter the pence to give: 3

Enter 1 for Sophie, 2 for Sally, or 0 to exit: 2
Enter 1 to give pence, 2 to give shillings, 3 to query her purse: 2
Enter the shillings to give: 2

Enter 1 for Sophie, 2 for Sally, or 0 to exit: 2
Enter 1 to give pence, 2 to give shillings, 3 to query her purse: 2
Enter the shillings to give: 1

Enter 1 for Sophie, 2 for Sally, or 0 to exit: 1
Enter 1 to give pence, 2 to give shillings, 3 to query her purse: 3
The purse has 3 pence, 0 shillings

Enter 1 for Sophie, 2 for Sally, or 0 to exit: 2
Enter 1 to give pence, 2 to give shillings, 3 to query her purse: 3
The purse has 0 pence, 3 shillings

Enter 1 for Sophie, 2 for Sally, or 0 to exit: 0

To get started, consider the following questions:

What are the major nouns of the scenario? Sophie, Sally, parents, pence, shilling, coin, purse

What are the relationships between these nouns?

Sophie and Sally each have purses. Having a Daughter or Child object might be possible, but in this scenario the only thing interesting about Sophie and Sally is that they each have a purse. We can treat them as names of different purse objects (i.e., they are variables of type Purse).

the parents are really just a euphemism for the user of the program. We have to interact with the user, but don't need a specific class.

pence and shillings are coins, but they also just count something--the int data type will represent them just fine

a purse contains pence and shillings, and we also need to add pence and shillings to a purse, and fetch its number of pence and shilling coins. This looks like an object.

Write a program to implement this scenario. Use two classes. One class should contain a main method and manage the dialog with the user. The other class should represent a Purse. The design of the Purse class is up to you. Make sure that your instance variables are private, follow the naming conventions, etc.

Answer-

Purse.java


public class Purse {

private int pence;
private int shilling;

public void incPence(int n)
{
pence+=n;
}
public void incshilling(int n)
{
shilling+=n;
}

public int getPence()
{
return pence;
}
public int getshilling()
{
return shilling;
}

}

========================================================================

DemoDriver.java

import java.util.Scanner;

public class DemoDriver {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
Purse sophie=new Purse();
Purse sally=new Purse();

while(true)
{
System.out.println("Enter 1 for Sophie, 2 for Sally, or 0 to exit: \n");
int girl=sc.nextInt();
int ch;
int pence,shill;
if(girl==1)
{
System.out.println("Enter 1 to give pence, 2 to give shillings, 3 to query her purse:\n");
ch=sc.nextInt();

if(ch==1)
{
System.out.println("Enter the pence to give:\n");
pence=sc.nextInt();
sophie.incPence(pence);

}else if(ch==2)
{
System.out.println("Enter the shillings to give:\n");
shill=sc.nextInt();
sophie.incshilling(shill);
}
else
{
System.out.println("Purse has "+sophie.getPence()+" pence,"+sophie.getshilling()+" shillings\n");
}
}
else if(girl==2)
{
System.out.println("Enter 1 to give pence, 2 to give shillings, 3 to query her purse:\n");
ch=sc.nextInt();

if(ch==1)
{
System.out.println("Enter the pence to give:\n");
pence=sc.nextInt();
sally.incPence(pence);

}else if(ch==2)
{
System.out.println("Enter the shillings to give:\n");
shill=sc.nextInt();
sally.incshilling(shill);
}
else
{
System.out.println("Purse has "+sally.getPence()+" pence,"+sally.getshilling()+" shillings\n");
}

}else
{
break;
}

}
}

}

Please include the final results in the answer above as it is missing and also remove the break method from code. Also change the while loop to For loop

Answers

Answer:

Java Programming

Details explained below.

Explanation:

import java.util.Scanner;

public class DemoDriver {

public static void main(String[] args) {

// TODO Auto-generated method stub

Scanner sc=new Scanner(System.in);

Purse sophie=new Purse();

Purse sally=new Purse();

while(true)

{

System.out.println("Enter 1 for Sophie, 2 for Sally, or 0 to exit: \n");

int girl=sc.nextInt();

int ch;

int pence,shill;

if(girl==1)

{

System.out.println("Enter 1 to give pence, 2 to give shillings, 3 to query her purse:\n");

ch=sc.nextInt();

if(ch==1)

{

System.out.println("Enter the pence to give:\n");

pence=sc.nextInt();

sophie.incPence(pence);

}else if(ch==2)

{

System.out.println("Enter the shillings to give:\n");

shill=sc.nextInt();

sophie.incshilling(shill);

}

else

{

System.out.println("Purse has "+sophie.getPence()+" pence,"+sophie.getshilling()+" shillings\n");

}

}

else if(girl==2)

{

System.out.println("Enter 1 to give pence, 2 to give shillings, 3 to query her purse:\n");

ch=sc.nextInt();

if(ch==1)

{

System.out.println("Enter the pence to give:\n");

pence=sc.nextInt();

sally.incPence(pence);

}else if(ch==2)

{

System.out.println("Enter the shillings to give:\n");

shill=sc.nextInt();

sally.incshilling(shill);

}

else

{

System.out.println("Purse has "+sally.getPence()+" pence,"+sally.getshilling()+" shillings\n");

}

}else

{

break;

}

}

}

} END.

Write a assembler code that displays the first 27 values in the Fibonacci series. One version will use 16 bit registers (ax, bx, cx, dx) and the the other version will use 32 bit registers (eax, ebx, ecx, edx). Use the authors' routine writeint to display the numbers. The 16 bit version will not display all the numbers correctly. The pseudo code is num1

Answers

Explanation:

yeah yeah is that we go together on the watch remember write a timer called that depressed display of the first 27 value in the XM Sirius

Assume that the following code segment C is executed on a pipelined architecture that will cause data hazard(s): Code segment C: add $s2, $t2, $t3 sub $t4, $s2, $t5 add $t5, $s2, $t6 and $t5, $t4, $t6 2 2.A.) (10 POINTS) First describe schematically, what will be the first data hazard that will occur in this code segment. Then, schematically provide a solution for the first data hazard that will occur in this code segment by using each of the following data hazard remedies. Please note that for each item below you apply the solution independently, i.e. each solution should be isolated from other solutions. Ignore any further data hazard your proposed solution may cause. So, only try to solve the first data hazard that will occur in the code segment C. 2.B.) (10 POINTS) rearranging the code statements, i.e. reorganizing the order of instructions in the original code segment C. 2.C.) (10 POINTS) nop, i.e. inserting nop operation(s) into the original code segment C. 2.D.) (10 POINTS) stalling, applying stalling operations(s) into the original code segment C. 2.E.) (10 POINTS) data forwarding, i.e. applying data forwarding towards instruction(s) in the original code segment C.

Answers

Answer:

See explaination

Explanation:

a) Reorganizing the code

ADD $s2 , $t2, $t3

ADD $t5, $s2, $t6

SUB $t4, $s2, $t5

AND $t5,$t4,$t6

The reordering of the instruction leads to less hazards as compared to before.

b) with NOP

ADD $s2 , $t2, $t3

NOP

NOP

SUB $t4, $s2, $t5

NOP

ADD $t5, $s2, $t6

NOP

NOP

AND $t5,$t4,$t6

c. Pipeline with stalls

see attachment please

d. pipeline with forwarding

see attachment

Which one of the following business names would be rated Incorrect for name accuracy? Answer McDonald's McDonald's H&M McDonalds Inc All of them

Answers

McDonald's H&M McDonalds Inc is incorrect for name accuracy.

Explanation:

The correct Name is McDonald's. But Mc Donald's H&M and McDonalds inc is incorrect for name accuracy.

McDonald's is a fast-food company based in America. It has its retail outlets throughout the world. It is very famous for its burgers and french fries. It is the world's second-largest employer in the private sector. It is a symbol of globalization as it has its outlets throughout the world.

The name 'McDonald's H&M' is incorrect for name accuracy since it amalgamates two distinct brand identities. While 'McDonalds Inc' may simply be missing an apostrophe, it is possibly acceptable, but 'McDonald's H&M' clearly combines unrelated trademarks.

When evaluating the list of business names provided for name accuracy, it's important to consider the standard format of business names and trademarks. Typically, the name 'McDonald's' is associated with the well-known fast-food chain, and is correctly punctuated with an apostrophe to indicate the possessive form, likely referring to the founder's name (McDonald).

'McDonald's H&M' would be incorrect for name accuracy, as it combines the names of two distinct and unrelated brands, McDonald's and H&M, which are independently operated and have separate trademark rights. 'McDonalds Inc' is missing the possessive apostrophe, which could be seen as a minor error, but might still be legally operational depending on registration specifics.

Therefore, out of the options given, 'McDonald's H&M' would be rated incorrect for name accuracy due to the improper combination of two separate brand identities into one business name.

The groups_per_user function receives a dictionary, which contains group names with the list of users. Users can belong to multiple groups. Fill in the blanks to return a dictionary with the users as keys and a list of their groups as values.
def groups_per_user(group_dictionary):
user_groups = {}
# Go through group_dictionary
for ___:
# Now go through the users in the group
for ___: # Now add the group to the the list of
# groups for this user, creating the entry
# in the dictionary if necessary
return(user_groups)
print(groups_per_user({"local": ["admin", "userA"],
"public": ["admin", "userB"],
"administrator": ["admin"] }))

Answers

The groups_per_user function receives a dictionary, which contains group names with the list of users.

Explanation:

The blanks to return a dictionary with the users as keys and a list of their groups as values is shown below :

def groups_per_user(group_dictionary):

   user_groups = {}

   # Go through group_dictionary

   for group,users in group_dictionary.items():

       # Now go through the users in the group

       for user in users:

       # Now add the group to the the list of

         # groups for this user, creating the entry

         # in the dictionary if necessary

         user_groups[user] = user_groups.get(user,[]) + [group]

   return(user_groups)

print(groups_per_user({"local": ["admin", "userA"],

       "public":  ["admin", "userB"],

       "administrator": ["admin"] }))

The missing statements in the program are:

for group,users in group_dictionary.items():for user in users:user_groups[user] = user_groups.get(user,[]) + [group]

The first missing instruction is to iterate through the group_dictionary.

To do this, we make use of the following enhanced for loop:

for group,users in group_dictionary.items():

The above statement would iterate through the keys and the values of the dictionary.

The next missing statement is to iterate through the values in users list

To do this, we make use of the following enhanced for loop:

for user in users:

Lastly, the group is added to the user list using:

user_groups[user] = user_groups.get(user,[]) + [group]

Read more about dictionary and lists at:

https://brainly.com/question/14353514

Write an application that allows a user to enter the names and birthdates of up to 10 friends. Continue to prompt the user for names and birthdates until the user enters the sentinel value ZZZ for a name or has entered 10 names, whichever comes first. When the user is finished entering names, produce a count of how many names were entered, and then display the names. In a loop, continuously ask the user to type one of the names and display the corresponding birthdate or an error message if the name has not been previously entered. The loop continues until the user enters ZZZ for a name. Save the application as BirthdayReminder.java.

Answers

Answer:

import java.util.Scanner;

public class BirthdayChecker

{

   public static void main(String[] args)

   {

       String sentinelValue = "ZZZ";

       final int size = 10;

       int count = 0;

       String name = null;

       String dateOfBirth = null;

       String[] namesArray = new String[size];

       String[] dateOfBirthsArray = new String[size];

     Scanner scanner = new Scanner(System.in);

       System.out.println("Enter name or enter ZZZ " +  "to quit");

       name = scanner.nextLine();

       while(!name.equals(sentinelValue) && count < 10)

       {

           System.out.println("Enter date of birth " +  "(dd-mm-yyyy)");

           dateOfBirth=scanner.nextLine();

           namesArray[count] = name;

           dateOfBirthsArray[count] = dateOfBirth;

           System.out.println("Enter name or enter " +

           "ZZZ to quit");

           name=scanner.nextLine();

           count++;

       }

       System.out.println("Count of namesArray = "+count);

       System.out.println("The entered namesArray are:");

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

       {

           System.out.println(namesArray[i]);

       }

       boolean criteria = true;

       boolean flag = false;

       while(criteria)

       {

           System.out.println("Enter name to " +

           "display date of birth or enter " +

           "ZZZ to quit");

           name = scanner.nextLine();

           if(name.equals(sentinelValue))

               criteria = false;

           else

           {

               for(int i = 0; i < count && !flag;

               i++)

               {

                   if(namesArray[i].equals(name))

                   {

                       flag = true;

                       dateOfBirth = dateOfBirthsArray[i];

                   }

               }

               if(flag)

               {

                   System.out.println("Date of Birth "

                   + "of " + name + " is "

                   + dateOfBirth);

               }

               else

               {

                   System.out.println("Date Of Birth "

                   + "of " + name + " is not flag");

               }

           }

           flag = false;

       }

   }

}

Explanation:

Run a while loop until the name is not ZZZ as well as the count of namesArray is less than 10. Display the information such as the name and count.Ask the user to enter the name and display its date of birth respectively. Check whether the user enters the sentinel value and then assign false to the variable  criteria. Go through the namesArray array using a for  loop until the flag value  is false. Check whether the current name in the namesArray array is equal to the  name entered by user, then update the flag variable to true Check whether the  value of the variable flag is true and then display the date of birth else display the error message.

The `BirthdayReminder` Java app lets users enter names and birthdates, then lookup birthdates by name until "ZZZ" is entered.

Here's a Java application named `BirthdayReminder` that fulfills the specified requirements:

```java

import java.util.Scanner;

public class BirthdayReminder {

   public static void main(String[] args) {

       Scanner scanner = new Scanner(System.in);        

       String[] names = new String[10];

       String[] birthdates = new String[10];

       int count = 0;        

       // Input loop to enter names and birthdates

       while (count < 10) {

           System.out.print("Enter name (ZZZ to end): ");

           String name = scanner.nextLine();            

           if (name.equals("ZZZ")) {

               break; // Exit loop if sentinel value ZZZ is entered

           }            

           names[count] = name;            

           System.out.print("Enter birthdate (MM/DD/YYYY): ");

           String birthdate = scanner.nextLine();

           birthdates[count] = birthdate;            

           count++;

       }        

       System.out.println("\nNumber of names entered: " + count);

       System.out.println("List of names entered:");

       for (int i = 0; i < count; i++) {

           System.out.println(names[i]);

       }        

       // Lookup loop to find birthdate by name

       while (true) {

           System.out.print("\nEnter a name to lookup birthdate (ZZZ to end): ");

           String lookupName = scanner.nextLine();            

           if (lookupName.equals("ZZZ")) {

               break; // Exit loop if sentinel value ZZZ is entered

           }            

           boolean found = false;

           for (int i = 0; i < count; i++) {

               if (names[i].equals(lookupName)) {

                   System.out.println("Birthdate of " + lookupName + " is " + birthdates[i]);

                   found = true;

                   break;

               }

           }

           

           if (!found) {

               System.out.println("Name not found. Please enter a valid name.");

           }

       }        

       scanner.close();

   }

}

Explanation:

1. **Data Structures**: Two arrays `names` and `birthdates` are used to store up to 10 names and their corresponding birthdates.

2. **Input Loop**: The program prompts the user to enter names and birthdates in a loop until either 10 names are entered or the user inputs "ZZZ". Each name and birthdate pair is stored in the respective arrays.

3. **Output**: After input is finished, the program displays the count of names entered and lists the names that were stored.

4. **Lookup Loop**: The program then enters a lookup loop where it prompts the user to enter a name to retrieve the corresponding birthdate. It continues this until the user inputs "ZZZ". If a valid name is entered, it searches the `names` array for a match and displays the associated birthdate; if not found, it informs the user accordingly.

5. **End of Program**: The program closes the scanner once all operations are completed.

This Java application effectively manages user input, data storage, and retrieval as specified, providing a straightforward way to handle names and birthdates with user interaction and error handling.

Run a Monte Carlo simulation on this vector representing the countries of the 8 runners in this race:


runners <- c("Jamaica", "Jamaica", "Jamaica", "USA", "Ecuador", "Netherlands", "France", "South Africa")


For each iteration of the Monte Carlo simulation, within a replicate() loop, select 3 runners representing the 3 medalists and check whether they are all from Jamaica. Repeat this simulation 10,000 times. Set the seed to 1 before running the loop.

Answers

Answer:

Explanation:

# Run Monte Carlo 10k

B <- 10000

results <- replicate(B, {

 winners <- sample(runners, 3)

 (winners[1] %in% "Jamaica" & winners[2] %in% "Jamaica" & winners[3] %in% "Jamaica")

})

mean(results)

All the questions are to run on the Application DATABASE Student(SID,SName,GPA,sizeHS); college(CName,State, Enroolment); Apply(SID,CName,Major,Decision) ;

PLEASE MAKE SURE THERE ARE NO DUPLICATES IN YOUR RESULTS

Q1.1: Get the names of all the students whose GPA>=3.8;

Q1.2:Get the names of all the students who applied to some college;

Q1.3: Get the names all the students who did not applied to any college;

Q1.4: Get the names and enrollment of all the colleges who received applications for a major involving bio;

Q1.5: Get all pairs of students who have the same GPA;

Q1.6: Get all the students who applied to both CS and EE majors;

Q7: Get all the students who applied to CS and not to EE;

Q1.8: Use subquery to answer Q1.6 & Q1.7;

Q1.9 :Get all colleges such that some other college is in the same state;

Q1.10: Get all students.with highest GPA--use the keyword EXISTS or NOT EXISTS to answer the query; hint; use a subquery

Q1.11: Now pair colleges with the name of their applicants.

Answers

Answer:

Check the explanation

Explanation:

Q1: SQL to list names of all the students whose GPA is above specific number:

select SName

from Student

where GPA >= 3.8;

Using the Student table we are able to get the details where the GPa is greater than the required value.

Q2: SQL to get list of names of all the students who applied to some college:

select SName from Student where SID in (

select distinct SID from Apply

);

Selecting the name of the students who are present in the Apply table.

Q3: SQL to get list of names all the students who did not apply to any college:

select SName from Student where SID not in (

select distinct SID from Apply

);

Selecting the name of the students who are not present in the Apply table.

Q4: SQL to get list of names and enrollment of all the colleges who received applications for a major involving bio:

select CName, Enrollment from College where CName in (

select CName from Apply where Major = 'Bio' and SID in (

select SID from Student

)

);

You are in charge of the IT division for a company that has 1,048,576 customers. Your boss asks you to decide between buying a database system from Vendor A or Vendor B. Both systems are the same price but Vendor B’s computer (computers are included in each system) has hardware that is 1000 times faster than that provided by vendor A. However, Vendor A’s system is based on an algorithm that returns a response to a query in time proportional to 10nlog2n machine operations where n is the number of customers in the database while Vendor B’s system is based on an algorithm that returns a response to a query in time proportional to 10n2 machine operations. Vendor A’s computer has a speed of 1 nanosecond (=10-9 seconds) per operation.


How long (in seconds, rounded correctly to three decimal places to the right of the decimal) would Vendor A’s system take to return a response to a query based on your current number of customers? seconds


How long (in seconds, rounded correctly to three decimal places to the right of the decimal) would Vendor B’s system take to return a response to a query based on your current number of customers? seconds

Answers

Final answer:

Calculations reveal that Vendor A's system would take 0.209 seconds, while Vendor B's system, despite having hardware 1000 times faster, would take an infeasible 10,973.839 seconds due to the different algorithms used. Thus, Vendor A's system is the superior choice for query speed.

Explanation:

To determine which database system to choose based on the query response times for 1,048,576 customers, we need to calculate the response times for both Vendor A and Vendor B given their respective algorithms and computer speeds.

For Vendor A, the time is proportional to 10nlog2n machine operations. Plugging in the number of customers we have:

TA = 10 * 1,048,576 * log2(1,048,576) * 10-9

We know that log2(1,048,576) = 20 because 220 = 1,048,576. So:

TA = 10 * 1,048,576 * 20 * 10-9 = 209,715.2 * 10-9 = 0.209 seconds (rounded to three decimal places)

For Vendor B, whose computer is 1000 times faster, the time is proportional to 10n2 machine operations.

TB = 10 * (1,048,576)2 * 10-9 / 1000

TB = 10 * 1,097,383,936,256 * 10-9 / 1000 = 1.097x1013 * 10-9 seconds = 10,973.839 seconds, which is not feasible for the system. Hence, Vendor A's system is clearly the better choice in terms of response time.

2) [13 points] You’ve been hired by Banker Bisons to write a C++ console application that determines the number of months to repay a car loan. Write value function getLoanAmount that has no parameters, uses a validation loop to prompt for and get from the user a car loan amount in the range $2,500-7,500, and returns the loan amount to function main. Write value function getMonth Payment that has no parameters, uses a validation loop to prompt for and get from the user the monthly payment in the range $50-750, and returns the monthly payment to function main. Write value function getInterestRate that has no parameters, uses a validation loop to prompt for and get from the user the annual interest rate in the range 1-6%, and returns the interest rate to function main. Here are the first lines of the three functions:

Answers

Answer:

Check the explanation

Explanation:

CODE:

#include <iostream>

#include <iomanip>

using namespace std;

double getLoanAmount() { // functions as per asked in question

double loan;

while(true){ // while loop is used to re prompt

cout << "Enter the car loan amount ($2,500-7,500): ";

cin >> loan;

if (loan>=2500 && loan <= 7500){ // if the condition is fulfilled then

break; // break statement is use to come out of while loop

}

else{ // else error message is printed

cout << "Error: $"<< loan << " is an invalid loan amount." << endl;

}

}

return loan;

}

double getMonthlyPayment(){ // functions as per asked in question

double monthpay;

while(true){ // while loop is used to re prompt

cout << "Enter the monthly payment ($50-750): ";

cin >> monthpay;

if (monthpay>=50 && monthpay <= 750){ // if the condition is fulfilled then

break; // break statement is use to come out of while loop

}

else{ // else error message is printed

cout << "Error: $"<< monthpay << " is an invalid monthly payment." << endl;

}

}

return monthpay;

}

double getInterestRate(){ // functions as per asked in question

double rate;

while(true){ // while loop is used to re prompt

cout << "Enter the annual interest rate (1-6%): ";

cin >> rate;

if (rate>=1 && rate <= 6){ // if the condition is fulfilled then

break; // break statement is use to come out of while loop

}

else{ // else error message is printed

cout << "Error: "<< rate << "% is an invalid annual interest rate." << endl;

}

}

return rate;

}

int main() {

cout << setprecision(2) << fixed; // to print with 2 decimal places

int month = 0; // initializing month

// calling functions and storing the returned value

double balance= getLoanAmount();

double payment= getMonthlyPayment();

double rate= getInterestRate();

rate = rate /12 /100; // as per question

// printing as per required in question

cout << "Month Balance($) Payment($) Interest($) Principal($)"<< endl;

while(balance>0){ // while the balance is more than zero

month = month + 1; // counting Months

// calculations as per questions

double interest = balance * rate;

double principal = payment - interest;

balance = balance - principal;

// printing required info with proper spacing

cout <<" "<< month;

cout <<" "<< balance;

cout <<" "<< payment;

cout <<" "<< interest;

cout <<" "<< principal << endl;

}

cout << "Months to repay loan: " << month << endl; // displaying month

cout << "End of Banker Bisons";

Kindly check the output in the attached image below.

Write a class named Episode. An instance of this episode class will represent a single episode of a TV show, with a title, a season number, and an episode number. For example "Friends, season 1, episode 1", or "The Wire, season 3, episode 5." Your class should have the following constructors and methods: A constructor that accepts three arguments: a String for the title, an int for the season number, and an int for the episode number. A constructor that accepts only a String, for the title, and sets the season and episode numbers to 1. A setter and getter for the title. (never mind the season and episode numbers.) A method named "equals", that accepts an Episode, and returns true if the title, season number and episode number are the same as the receiving object's. A method named "comesBefore". This method should also accept an Episode. It should return true if the episode that receives the invocation comes before the parameter. That is only true if the two objects have the same title, and if the argument comes from a later season, or the same season, but a later episode. Write only the class. Do not write a whole program

Answers

Answer:

See explaination

Explanation:

class Episode{

//Private variables

private String title;

private int seasonNumber;

private int episodeNumber;

//Argumented constructor

public Episode(String title, int seasonNumber, int episodeNumber) {

this.title = title;

this.seasonNumber = seasonNumber;

this.episodeNumber = episodeNumber;

}

//Getter and setters

public String getTitle() {

return title;

}

public void setTitle(String title) {

this.title = title;

}

public int getSeasonNumber() {

return seasonNumber;

}

public void setSeasonNumber(int seasonNumber) {

this.seasonNumber = seasonNumber;

}

public int getEpisodeNumber() {

return episodeNumber;

}

public void setEpisodeNumber(int episodeNumber) {

this.episodeNumber = episodeNumber;

}

public boolean comesBefore(Episode e){

//Check if titles' match

if(this.title.equals(e.getTitle())){

//Compare season numbers

if(this.seasonNumber<e.seasonNumber){

return true;

}

//Check if season numbers match

else if(this.seasonNumber==e.getSeasonNumber()){

return this.episodeNumber<e.getEpisodeNumber();

}

}

return false;

}

atOverride // replace the at with at symbol

public String toString() {

return title+", season "+seasonNumber+", episode "+episodeNumber;

}

}

class Main{

public static void main(String[] args) {

Episode e = new Episode("Friends",1,1);

System.out.println(e);

Episode e2 = new Episode("The Wire",3,5);

System.out.println(e2);

System.out.println(e.getTitle()+" comes before "+e2.getTitle()+" = "+e.comesBefore(e2));

}

}

Create a class called Animal that accepts two numbers as inputs and assigns them respectively to two instance variables: arms and legs. Create an instance method called limbs that, when called, returns the total number of limbs the animal has. To the variable name spider, assign an instance of Animal that has 4 arms and 4 legs. Call the limbs method on the spider instance and save the result to the variable name spidlimbs.

Answers

class Animal:

   def __init__(self, arms, legs):

       self.arms = arms

       self.legs = legs

   

   def limbs(self):

       return self.arms + self.legs

# Creating an instance of Animal named spider with 4 arms and 4 legs

spider = Animal(4, 4)

# Calling the limbs method on the spider instance and saving the result to spidlimbs

spidlimbs = spider.limbs()

print("Number of limbs of the spider:", spidlimbs)

Part A [10 points] Create a class named Case that represents a small bookbag/handbag type object. It should contain: Fields to represent the owner’s name and color of the Case. This class will be extended so use protected as the access modifier. A constructor with 2 parameters – that sets both the owner’s name and the color. Two accessor methods, one for each property. (getOwnerName, getColor) A main method that creates an instance of this class with the owner’s name set to ‘Joy’ and color set to ‘Green’. Add a statement to your main method that prints this object. Run your main method again. Is this what you think should be displayed when this object is printed? Override the toString() method and return a string. For your Case object created in the previous step the string should be: "Case Owner : Joy , Color : Green"

Answers

Answer:

What

Explanation:

what

what

Research 3 distributions that utilize the big data file systems approaches, and summarize the characteristics and provided functionality. Research 3 distributions that utilize other NoSQL or NoSQL approaches, and summarize the characteristics and provided functionality. Compare and contrast how these technologies differ and the perceived benefits of each. Provide examples as necessary.

Answers

Answer:

Explanation:

1: The three most popular data systems that make use of Big Data file systems approach are:

The HDFS (Hadoop Distributed File System), Apache Spark, and Quantcast File System(QFS).

HDFS is the most popular among these and it makes use of the MapReduce algorithm to perform the data management tasks. It can highly tolerate faults and can run on low-cost hardware. It was written in Java and it is an open-source software.

Apache Spark makes use of Resilient Distributed Data (RDD) protocol. It is much faster and lighter than the HDFS and it can be programmed using a variety of languages such as Java, Scala, Python, etc. Its main advantage over HDFS is that it is highly scalable.

While QFS was developed as an alternative to the HDFS and it is also highly fault-tolerant and with space efficient. It makes use of the Reed-Solomon Error Correction technique to perform the task of data management.

2: The NewSQL databases were developed as a solution to the scalability challenges of the monolithic SQL databases. They were designed to allow multiple nodes in the context of an SQL database without affecting the replication architecture. It worked really well during the starting years of the cloud technology. Some of the databases that make use of New SQL technology are Vitess, Citus, etc.

Vitess was developed as an automatic sharding solution to the MySQL. Every MySQL instance acts as a shard of the overall database and each of these instances uses standard MySQL master-slave replication to ensure higher availability.

While, Citus is a PostgreSQL equivalent of the Vitess. It ensures transparent sharding due to which it accounts for horizontal write scalability to PostgreSQL deployments.

NoSQL database technology was developed to provide a mechanism for the storage and retrieval of data that is modeled in a way other than the tabular relations used in the traditional databases (RDBMS). The most popular database that makes use of the NoSQL technology is MongoDB. It functions as a cross-platform document-oriented database. It is known for its ability to provide high availability of replica sets. A replica set is nothing but a bundle of two or more copies of the data

A certain computer has a three-stage pipeline where Stage 1 takes 40 ns, Stage 2 takes 26 ns, and Stage 3 takes 29 ns to operate. What is the maximum achievable MIPS value (to one decimal place) for this computer

Answers

Answer:

40 ns would be the maximum MIPS value to be achieved for this computer.

Answer:

MIPS = 10.53

Explanation:

To find the maximum allowable MIPS, we need to obtain the total maximum time for an instruction to be executed by the CPU.

Total time to complete 1 instruction for the computer will entail the instruction passing through the 3 stages.

Total time to complete 1 instruction = 40 + 26 + 29 = 95 ns = (95 × 10⁻⁹) s

MIPS = millions instructions per second and it is given as

(Number of instruction)/(execution time × 1,000,000)

MIPS = 1/(95 × 10⁻⁹ × 10⁶)

MIPS = 10.53

Hope this Helps!!!

Other Questions
My reaction time was 0.7268 seconds the first time and 0.3883 the second time. What was yours Expansionary / RecoveryP = Peak C = Contractionary/Recession T = Trough 1.________ The price of bread has increased 5% over the past three months. 2.________ Interest rates at a low of 2% cause consumers to take out loans and buy homes. 3.________ The sale of all goods and services are down for the 5th consecutive month. 4.________ Due to factory closures unemployment has risen to a five year high of 10% 5.________ Due to increased consumer spending, the Federal Reserve raises interest rates to slow the economy down. 6.________ The DOW Jones industrial average (Stock prices) reaches an all-time high. 7.________ GDP declines for four consecutive months, causing the Federal Reserve to lower interest rates. 8.________ The unemployment rate is at 3.4%, a new 15 year low. 9.________ The economy has maxed out and is no longer growing.10._____ What is the next phase after experiencing a Trough. The design of a concrete mix requires 2,314 lb/yd3 of gravel having a moisture content of 3.5% and absorption of 4.2%, and 899 lb/yd3 of sand having a moisture content of 5.7% and absorption of 1.4%, and 244 lb/yd3 of free water. What is the weight of the mixing water per cubic yard that should be used at the job site? The Movie Haven is planning to order new medium-size popcorn containers. It has a choice of four different containers. It costs the company $0.02 per cubic inch of popcorn to fill a container. The company does not want the new container to cost more than $3.00 to fill. Which container should the company use? Use 3.14 for Pi. The mean absolute deviation is 0.1 what conclusions can be drawn A. The data points are closer to the media. B. The data points are far from the median C. The data points are far from the mean D. The data points are close to the mean What is a theme of Frightful' s Mountain? What are 3 examples of the theme in the story. PLs help! Which unit of measurement can be used to express the volume of this prism cmo se conecta la identidad publica y privada de un individuo? Mary bakes a chocolate cake, a vanilla cake, and a strawberry cake. Each cake is the same size. Angela eats four-eighths of the chocolate cake, two-eighths of the vanilla cake, and two-fourths of the strawberry cake. David eats one-fourth of the chocolate cake, three-eighths of the vanilla cake, and one-half of the strawberry cake. Who eats more cake, Angela or David? How much more cake? How much of each cake is left? Show all your mathematical thinking. How did monsoon flooding affect the development of civilizations in the Indus River Valley? how many times larger is 2000 than 2 How many grams of O2 are needed to produce 0.400 mole Fe2O3 in the following reaction?4 Fe(s) + 3 028 2 Fe2O3(s) bradly has 10 apples he gives 2 apples to tuimmy. how many apples does timmy have? What were the effects of the fall of the Western Roman Empire? Choose three correct answers.Rome prospered despite being invaded,Trade and the size of cities decreased dramaticallyRome began to grow many crops to increase tradeThe Eastern Roman Empire continued for another thousand yearsWestern and Eastern Europe developed different religious and cultural traditions Which picture represents a cast? Explain how the exterior angle relates to the interior angles. Political parties are uppose that the one-year forward dollar price of a euro is $1.36. Further, assume that the spot exchange rate is $1.28 per euro, and that the interest rate on dollar deposits is 6 percent. What is the interest rate on Euro deposits that would make interest parity hold Brian says that there is no such thing as an acute triangle that also has a 90 degree angle. Is this statement true? Yes or No?Explain you reasoning about Brian's statement In 1914 , the only two countries in Africa that the Europeans did not control were what?