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

Answer 1

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.


Related Questions

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)

Purpose of this project is to increase your understanding of data, address, memory contents, and strings. You will be expected to apply selected MIPS assembly language instructions, assembler directives and system calls sufficient enough to handle string manipulation tasks. You are tasked to develop a program that finds how many times a word is used in a given statement. To test your program, you should hardcode the below sample statement in your code, and ask user to input two different words, which are "UCF" and "KNIGHTS" in this project, however your code should work for any words with less than 10 characters. Your program should not be case sensitive and regardless of the way user inputs the words it should correctly find the words.

Sample Statement: UCF, its athletic program, and the university's alumni and sports fans are sometimes jointly referred to as the UCF Nation, and are represented by the mascot Knightro. The Knight was chosen as the university mascot in 1970 by student election. The Knights of Pegasus was a submission put forth by students, staff, and faculty, who wished to replace UCF's original mascot, the Citronaut, which was a mix between an orange and an astronaut. The Knights were also chosen over Vincent the Vulture, which was a popular unofficial mascot among students at the time. I11 1994, Knightro debuted as the Knights official athletic mascot.

Sample Output: Please input first word: Knight (or KnIGhT, knight, ...) Please input second word: UCF (or ucf, UcF, ...)

KNIGHT: - 6
UCF: ----3

Answers

Final answer:

You are developing a MIPS assembly language program for string manipulation to count how many times two user-input words occur in a hardcoded statement. It must handle case insensitivity and work with any words of less than 10 characters.

Explanation:MIPS Assembly Language Project

Your project involves writing a MIPS assembly language program that processes a given statement to find the frequency of occurrences of certain words. The program's main goal is to enhance your understanding of data, address, memory contents, and strings. With this program, you are expected to use MIPS instructions, assembler directives, and system calls for string manipulation.

To achieve this, you must first hardcode the provided sample statement into your program. Next, your program must prompt the user to input two words ('UCF' and 'KNIGHTS', or any other word with less than 10 characters) and count how many times each occurs in the statement. The challenge is to ensure the search is not case sensitive, meaning it should treat 'UCF', 'ucf', or 'UcF' as the same word.

To do this, you might consider converting the entire statement to lowercase, as well as the user's input, before performing the search. This standardized form avoids missing occurrences due to case differences. When the user enters the chosen words, the program outputs the count for each, formatted as shown in the sample output.

Write a program that prompts the user to enter an equation in the form of 10 5, or 10-5, or 1*5, or 13/4, or 13%4. The program should then output the equation, followed by an equal sign, and followed by the answer.

Answers

Answer:

equation = input("Enter an equation: ") if("+" in equation):    operands = equation.split("+")    result = int(operands [0]) + int(operands[1])    print(operands[0] + "+" + operands[1] + "=" + str(result)) elif("-" in equation):    operands = equation.split("-")    result= int(operands [0]) - int(operands[1])    print(operands[0] + "-" + operands[1] + "=" + str(result))   elif("*" in equation):    operands = equation.split("*")    result = int(operands [0]) * int(operands[1])    print(operands[0] + "*" + operands[1] + "=" + str(result))   elif("/" in equation):    operands = equation.split("/")    result = int(operands [0]) / int(operands[1])    print(operands[0] + "/" + operands[1] + "=" + str(result))  elif("%" in equation):    operands = equation.split("%")    result = int(operands [0]) % int(operands[1])    print(operands[0] + "%" + operands[1] + "=" + str(result))

Explanation:

The solution code is written in Python 3.

Firstly prompt user to enter an equation using input function (Line 1).

Create if-else if statements to check if operator "+", "-", "*", "/" and "%" exist in the input equation. If "+" is found (Line 3), use split method to get the individual operands from the equation by using "+" as separator (Line 5). Output the equation as required by the question using string concatenation method (Line 6).  The similar process is repeated for the rest of else if blocks (Line 7 - 22).  

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

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)

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

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

Write a program that allows the user to enter as many sets of 2 numbers as needed. For each set of two numbers, compute the Greatest Common Factor (GCF) of the two numbers. The program should do the followings: 1. Allow the user to enter as many sets as needed. 2. After the user enters all the numbers, display each set of two numbers and the GCF for these two numbers. 3. The function to find GCF must be a recursive function. Here is the definition: GCF (n,m)

Answers

Answer:

#include<iostream>

#include<iomanip>

using namespace std;

//recursive method to find the GCF of two numbers

int GCF(int n, int m){

               //case 1, if m<=n and n mod m is 0, then gcf is m

               if(m<=n && n%m==0){

                               return m;

               }

               //case 2, if n<m, then gcf= GCF(m,n)

               if(n<m){

                               return GCF(m,n);

               }

               //otherwise, returning GCF(m, n mod m)

               return GCF(m,n%m);

}

int main(){

               //declaring two arrays of size 100 to store the set of first and second numbers

               //and a count

               int first[100], second[100], count=0;

               char ch;

               //asking user if he likes to enter two numbers, reading choice

               cout<<" Would you like to enter two numbers? ";

               cin>>ch;

               //looping as long as ch is 'y' or 'Y'

               while(ch=='y' || ch=='Y'){

                               //prompting and reading numbers to first and second

                               cout<<endl<<"Please enter two numbers ";

                               cin>>first[count]>>second[count];

                               //updating count, asking again

                               count++;

                               cout<<" Would you like to enter two numbers? ";

                               cin>>ch;

               }

             

               //left justifying output and printing a blank line

               cout<<left<<endl;

               //using a field with of 10, printing each column header

               cout<<setw(10)<<"First #";

               cout<<setw(10)<<"Second #";

               cout<<setw(10)<<"GCF"<<endl;

               //printing separators

               cout<<setw(10)<<"=======";

               cout<<setw(10)<<"========";

               cout<<setw(10)<<"==="<<endl;

               //looping through the arrays

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

                               //displaying both numbers and their GCF

                               cout<<setw(10)<<first[i];

                               cout<<setw(10)<<second[i];

                               cout<<setw(10)<<GCF(first[i],second[i])<<endl;

               }

               return 0;

}

Explanation:

Run the program and see the output

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.

If a small monster collector has 20 small monster containment devices; intends to use all of those devices; has access to non-unique Water, Fire and Grass type small monsters; intends to capture at least two small monsters of each type; and intends to capture at least three Fire-type small monsters - how many different combinations of small monster types can that collector capture?

Answers

In mathematics, a combination refers to a method of selecting items from a sample where the order in which the elements of the sample are arranged does not matter.

What is the formula for Combination?

C = (n, r) = [tex]\frac{n!}{(r!(n-r)!)}[/tex]

where n is the number of objects and

r the sample.

There are 3 categories of monsters:

non-unique WaterFire andGrass-type small monsters;

He intends to catch at least two of each type. This is represented mathematically as:

C(3, 2) = 3!/(2!(3-2)!)

= 3!/2! x1!

= 3

He also intends to capture at least three fire-type monsters.

This is represented as:

C (3, 1) = 3!/(1!(3-1)!)

= 3!/1!x2!

= 3

Hence the different number of combinations are:

3+3 = 6

Learn more about Combinations at:

https://brainly.com/question/11732255



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:

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"))

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.

Network layer functionalities can be broadly divided into data plane functionalities and control plane functionalities. What are the main functions of the data plane? Of the control plane?

Answers

Answer:

See explaination for the main functions of the data plane and Of the control plane.

Explanation:

A Data plane is used in a network, it is also known as forwarding plane. The main responsibility of a data plane is to carry forward the packets or data between different clients of the network.

A Control plane used in the network is responsible for establishing a connection information. That is a Control plane connects different controls by exchanging their routing and forwarding information.

Answer:

Data plane forwards data packets using the commands passed by the control plane Data plane transfer data between clients making use of the forwarding table found in the control plane  Data plane manages the network traffic of the control plane

Explanation:

The data plane is the found in a network control plane. it is used for the transfer of data between clients using the commands/instructions passed to it by the control plane to perform such function.

The Data plane is also known as forwarding plane because of its main functionality of carrying data for one client to another . A control plane is used for the connection of clients thereby establishing connection information. A control plane those this by exchanging forwarding routing information between clients

(NumberFormatException)Write the bin2Dec(String binaryString) method to convert a binary string into a decimal number. Implement the bin2Dec method to throw a NumberFormatException if the string is not a binary string. Write a test program that prompts the user to enter a binary number as a string and displays decimal equivalent of the string. If the method throws an exception, display "Not a binary number".Sample Run 1Enter a binary number: 1015Sample Run 2Enter a binary number: 41Not a binary number: 41Class Name: Exercise12_07

Answers

Following are the program to the given question:

Program Explanation:

Import package.Defining a class "Exercise12_07".Inside a class defining a method "bin2Dec" that takes a string variable as a parameter.In the method, it converts binary digits to decimal number with the help of exception and returns its value.Defining a main method, inside the method string variable is define that inputs value.After input try and catch block are used that checks value and print its value.

Program:

// package

import java.util.*;

public class  Exercise12_07 // class Exercise12_07

{

   //defining method

   public static int bin2Dec(String binaryString) throws NumberFormatException //method bin2Dec that takes a one String parameter

   {

       int t = 0,i;//defining Integer variable

       for(i = 0; i < binaryString.length(); ++i)//defining loop that converts binary to decimal convert  

       {

           if(binaryString.charAt(i) != '0' && binaryString.charAt(i) != '1')//using if that checks binary digit with Exception

           {

               throw new NumberFormatException();//calling Exception

           }

           t += Math.pow(2, binaryString.length() - i - 1) * (binaryString.charAt(i) - '0');//converting and holding Decimal number

       }

       return t;//return value

   }

   public static void main(String[] a) //main method

   {

       Scanner inxv = new Scanner(System.in);//defining Scanner class Object

       System.out.print("Enter a binary number: ");//print message

       String str = inxv.nextLine();//defining String variable and input value

       try //defining try block

       {

           System.out.println("Decimal value of " + str + " is " + bin2Dec(str));//using print method to print method return value  

       }  

       catch (NumberFormatException e)//defining catch block

       {

           System.out.println("Not a binary number: " + str);//print message

       }

   }

}

Output:

Please find the attachment file.

Learn more:

brainly.com/question/19755688

A contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. Write a program that first takes in word pairs that consist of a name and a phone number (both strings). That list is followed by a name, and your program should output the phone number associated with that name. Ex: If the input is: Joe 123-5432 Linda 983-4123 Frank 867-5309 Frank the output is:

Answers

The question is asking to create a program for a contact list, where users can input name-number pairs and then retrieve a number by inputting a name. This represents a fundamental database functionality, which can be programmed using associative arrays or dictionaries in most programming languages.

The student is essentially asking for a simple contact list program which stores names and phone numbers and retrieves a phone number when a name is provided. In context, this is a basic database operation. A typical approach to this problem would involve associative arrays or dictionaries commonly used in programming. For instance, in Python, the program would look something like this:

contacts = {}

while True:

   name = input()

   if name == '':

       break

   number = input()

   contacts[name] = number

search_name = input()

print(contacts.get(search_name, 'Name not found.'))

The student could adapt this program to further include other contact details, such as email addresses and birthdates. A more complex version may involve one-to-many or many-to-many relationships where an individual could have multiple phone numbers or emails, and vice versa.

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

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;

}

Consider the following code: // Merge mailing list m2 into m1 void merge (MailingList m1, MailingList m2) { for (int i = 0; i < m2.numEntries(); ++i) m1.add (m2.getEntry(i)); } The programmers who first encountered this code fragment weren’t sure if it was in C++ or Java. In fact, with the addition of some appropriate declarations, it would probably compile correctly in either language. Which language is it? Explain your answer.

Answers

Answer:

That is a Java language

Explanation:

This is simply Because C++ language does not support the calling of the methods without parameters and with the .(dot) operator.

It can also be clearly noted that This is the functionality of Java, for example, to sort we call Array.Sort().

So the parameter here is passed by placing the variable at front with the . (dot).

Develop a list of privacy protection features that should be present if a website is serious about protecting privacy. Then, visit at least four well-known websites and examine their privacy policies. Write a report that rates each of the websites on the criteria you have developed.

Answers

Final answer:

To assess how seriously a website takes privacy, one should review their privacy policy and assess features like encryption, data control, and transparency. Individuals can protect their privacy by familiarizing themselves with these policies and using best practices for data security. Government systems' treatment of privacy rights and the paradox of tolerance play roles in overall online privacy.

Explanation:

Essential Privacy Protection Features for Websites

When evaluating whether a website is serious about protecting user privacy, certain features should be present. These features include clear and accessible privacy policies, secure data encryption, options for users to control their personal information, regular security audits, transparent data collection practices, and mechanisms for user data requests and deletions.

Rating Websites on Privacy Practices

To rate websites based on these criteria, one would need to review the privacy policies of at least four well-known websites. The review should assess how each site handles user data, the level of control provided to users, the security measures in place to protect personal information, and the transparency of their data processing activities.

Privacy rights are a fundamental part of online security, and users should be acquainted with them. Individuals can protect their data privacy by becoming familiar with privacy policies, limiting personal information shared online, and utilizing security measures like two-factor authentication. Websites that rate highly in these areas show a commitment to user privacy.

It is also important to conduct sociological research regarding the type and amount of personal information available online. Identifying what personal details are accessible through public records or sold by data brokers can inform an individual's approach to online privacy.

Analyzing Government Approaches and the Paradox of Tolerance

Comparing how different government systems recognize privacy rights can highlight the diverse approaches taken worldwide. Addressing the paradox of tolerance is significant when considering privacy protection, as it often involves balancing individual rights with broader societal security concerns.

Finally, a thorough investigation of the websites' authorship and reputation can provide insight into their reliability and trustworthiness, serving as a secondary measure of their commitment to protecting user privacy.

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!!!

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

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.

stock purchase the following steps calculate the amount of a stock purchase. (a) create the variable costpershare and assign it the value 25.625. (b) create the variable numberofshares and assign it the value 400. (c) create the variable amount and assign it the product of the values of costpershare and numberofshares. (d) display the value of the variable amount. step by step

Answers

Answer:

#include<iostream>

#include<conio.h>

using namespace std;

main()

{

int numberofshares;

float costpershare, amount;

costpershare= 25.625;

numberofshares = 400;

amount = costpershare*numberofshares;

cout<<"\nTotal amount of Stock Purchase =" << amount;

getch();

}

Explanation:

In above mentioned program, total amount of stock purchase need to be calculated for given data. The values 25.625 and 400 assigned to the variables of cost per share and  number of shares.

The formula to calculate the total amount of stock purchase is simply Multiplication of cost and total number of shares. The output will be displayed with the help of variable named as amount.

Solution

Cost per Share = 25.625

Number of shares = 400

amount = cost per share * Number of shares

              =   25.625 * 400

              =    10,250

Final answer:

To calculate the amount of a stock purchase, create variables for cost per share and number of shares, and then multiply them together to find the total amount.

Explanation:

To calculate the amount of a stock purchase:

Create the variable costpershare and assign it the value 25.625.Create the variable numberofshares and assign it the value 400.Create the variable amount and assign it the product of the values of costpershare and numberofshares.Display the value of the variable amount.

Following these steps, the amount of the stock purchase can be determined by multiplying the cost per share by the number of shares.

Calculate the total number of bits transferred if 200 pages of ASCII data are sent using asynchronous serial data transfer. Assume a data size of 8 bits, 1 stop bit, and no parity. Assume each page has 80x25 of text characters.

Answers

Answer:

4000000 bits

Explanation:

The serial port configuration in asynchronous mode actually assumes a data size of 8bits, 1 start bit, no parity and 1 stop bit.

Therefore 8+1+1 = 10 bits.

This means that for every eight bits of data, ten bits are sent over the serial link — one start bit, the eight data bits, and the one stop bit)

We also know that there are 200 pages of ASCII data using asynchronous serial data transfer and each page has 80*25 of text characters.

Therefore the total number of bits transferred:

200*80*25*10 = 4000000 bits

200 pages of ASCII data, each with 80x25 characters, results in 4,000,000 bits transferred using asynchronous serial transfer with 8 data bits, 1 start bit, and 1 stop bit per character. Each character is 8 bits, totaling 10 bits per transfer including overhead.

To calculate the total number of bits transferred when sending 200 pages of ASCII data using asynchronous serial data transfer, we first need to determine the number of characters per page, and then multiply that by the total number of pages. Each ASCII character is represented by 8 bits (1 byte). Additionally, we need to consider the start bit, stop bit, and any potential overhead.

Given:

- ASCII character size: 8 bits

- 1 start bit

- 1 stop bit

- No parity

Each character will be transferred as:

1 (start bit) + 8 (ASCII data) + 1 (stop bit) = 10 bits per character.

Let's calculate:

1. Number of characters per page:

  - Each page has 80 characters per row and 25 rows.

  - Total characters per page = 80 × 25 = 2000 characters.

2. Total bits per page:

  - Total bits per page = 2000 characters × 10 bits/character = 20000 bits.

3. Total bits for 200 pages:

  - Total bits for 200 pages = 200 × 20000 bits = 4,000,000 bits.

So, the total number of bits transferred would be 4,000,000 bits.

Universal containers has two teams: Sales and Services. Both teams interact with the same records. Sales users use ten fields on the Account Record. Services users use three of the same fields as the Sales team, but also have five of their own, which the sales team does not use .What is the minimum configuration necessary to meet this requirement?

Answers

Answer:

Two profiles, one record type, two page layouts.

Explanation:

Record types and functions allow you to present forward different business processes, pick-list values, as well as page layouts to diverse range of users based on their profiles.

Going by the question, we can conclude that the minimum necessary configuration in order to meet the requirement in the question above are:Two profiles, one record type, two page layouts.

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 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.

Create a project named ClassicBookSelector that contains a Form with a ListBox that lists at least five classic books that you think all educated people should have read. When the user places the mouse over the ListBox, display a Label that contains a general statement about the benefits of reading. The Label disappears when the user’s mouse leaves the ListBox area

Answers

Answer:

See explaination

Explanation:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace BookListBox

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

string[] Book={"In Search of Lost Time","Ulysses","Don Quixote","The Great Gatsby","One Hundred Years of Solitude"};//declare variable book name

string[] Book_displayMessage = { "In Search of Lost Time by Marcel Proust", " Ulysses by James Joyce", "Don Quixote by Miguel de Cervantes", " The Great Gatsby by F. Scott Fitzgerald", "One Hundred Years of Solitude by Gabriel Garcia Marquez" };//declare variable Short dispay

string[] Book_BrienfSynpsis = { "Swann's Way, the first part of A la recherche de temps perdu, Marcel Proust's seven-part cycle, was published in 1913. In it, Proust introduces the themes that run through the entire work. ", "Ulysses chronicles the passage of Leopold Bloom through Dublin during an ordinary day, June 16, 1904.", "Alonso Quixano, a retired country gentleman in his fifties, lives in an unnamed section of La Mancha with his niece and a housekeeper.", "The novel chronicles an era that Fitzgerald himself dubbed the Jazz Age. ", "One of the 20th century's enduring works, One Hundred Years of Solitude is a widely beloved and acclaimed novel known throughout" };//declare variable Brienf synpsis

private void Form1_Load(object sender, EventArgs e)

{

lblBriefSynopsis.Text = "";//blank display textbox

lbldisplaymessage.Text="";//blank display textbox

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

lbbook.Items.Add(Book[i]);//add book to listbox

}

private void lbbook_MouseHover(object sender, EventArgs e)

{

Point point = lbbook.PointToClient(Cursor.Position);

int index = lbbook.IndexFromPoint(point);

if (index < 0) return;

//Do any action with the item

lbldisplaymessage.Text = "Here is the Short things about it"+Environment.NewLine+Book_displayMessage[index];

}

private void lbbook_MouseLeave(object sender, EventArgs e)//mouse leave event here

{

lbldisplaymessage.Text = "";//here display message will blank textbox

}

private void lbbook_SelectedIndexChanged(object sender, EventArgs e)

{

}

private void lbbook_MouseClick(object sender, MouseEventArgs e)

{

lblBriefSynopsis.Text = Book_BrienfSynpsis[lbbook.SelectedIndex];//display click brienf Synposis

if (lbbook.SelectedIndex % 5 == 0)

this.BackColor=Color.Blue;

else if (lbbook.SelectedIndex % 5 == 1)

this.BackColor = Color.Red;

else if (lbbook.SelectedIndex % 5 == 2)

this.BackColor = Color.Purple;

else if (lbbook.SelectedIndex % 5 == 3)

this.BackColor = Color.Pink;

else if (lbbook.SelectedIndex % 5 == 4)

this.BackColor = Color.Orange;

}

}

}

A professor gives 100-point exams that are graded on the scale 90-100: A, 80-89: B, 70-79:C, 60-69: D, <60: F. Write a Python function, grade(score), that takes a score as an input parameter and returns the corresponding letter grade. You are only allowed to use ONE if-statement with ONE elif or else for this problem. Write a main() function that prompts the user for a score, then calls your grade() function and finally prints the grade. Hint: think about how chr() could be used.

Answers

Answer:

score = int(input('Enter Score: '))

print('The Grade is:',end=' ')

if score >= 90:

print('A')

elif score >= 80:

print('B')

elif score >= 70:

print('C')

elif score >= 60:

print('D')

else:

print('F')

PROGRAM DESCRIPTION: In this assignment, you will write two complete C programs that will allow two players to play the game of network tic-tac-toe. It will include two programs, a server and a client. The server will allow two clients to connect and then will begin the game. The client programs accept input from the player and transmits the command to the server which will execute the commands and send a reply back to the client programs. The client and server programs are to communicate via the Internet (network) using TCP sockets. Your server should be able to handle commands from either client in any order. Your clients should be able to handle responses from the server or the player. (hint: use select) The game is for two players on a 3x3 grid. The player who moves first uses X marks. The second player uses O marks. Each player takes turns placing their mark (XJO) on an empty spot on the grid. The game ends when all spots have a mark or either player has 3 marks in a row. REQUIREMENTS: Your code should be well documented in terms of comments. For example, good comments in general consist of a header (with your name, course section, date, and brief description), comments for each variable, and commented blocks of code. Your server should be named "minor4server.c". without the quotes. Your client should be named "minor4client.c", without the quotes. Your programs will be graded based largely on whether it works correctly on the CSE machines (e.g., cse01, cse02, ..., cse06), so you should make sure that your scripts do not have any runtime errors and runs on a CSE machine. This is an individual programming assignment that must be the sole work of the individual student. Any instance of academic dishonesty will result in a grade of "F" for the course, along with a report filed into the Academic Integrity Database.

Answers

Answer:

Explanation:

minor4server.c:

#include <pthread.h>

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <unistd.h>

#include <sys/types.h>

#include <sys/socket.h>

#include <netinet/in.h>

int player_count = 0;

pthread_mutex_t mutexcount;

void error(const char *msg)

{

perror(msg);

pthread_exit(NULL);

}

/* Reads an int from a client socket. */

int recv_int(int cli_sockfd)

{

int msg = 0;

int n = read(cli_sockfd, &msg, sizeof(int));

if (n < 0 || n != sizeof(int)) /* Client likely disconnected. */

return -1;

#ifdef DEBUG

printf("[DEBUG] Received int: %d\n", msg);

#endif

return msg;

}

/* Writes a message to a client socket. */

void write_client_msg(int cli_sockfd, char * msg)

{

int n = write(cli_sockfd, msg, strlen(msg));

if (n < 0)

error("ERROR writing msg to client socket");

}

/* Writes an int to a client socket. */

void write_client_int(int cli_sockfd, int msg)

{

int n = write(cli_sockfd, &msg, sizeof(int));

if (n < 0)

error("ERROR writing int to client socket");

}

/* Writes a message to both client sockets. */

void write_clients_msg(int * cli_sockfd, char * msg)

{

write_client_msg(cli_sockfd[0], msg);

write_client_msg(cli_sockfd[1], msg);

}

/* Writes an int to both client sockets. */

void write_clients_int(int * cli_sockfd, int msg)

{

write_client_int(cli_sockfd[0], msg);

write_client_int(cli_sockfd[1], msg);

}

/* Sets up the listener socket. */

int setup_listener(int portno)

{

int sockfd;

struct sockaddr_in serv_addr;

/* Get a socket to listen on */

sockfd = socket(AF_INET, SOCK_STREAM, 0);

if (sockfd < 0)

error("ERROR opening listener socket.");

 

/* Zero out the memory for the server information */

memset(&serv_addr, 0, sizeof(serv_addr));

 

  /* set up the server info */

serv_addr.sin_family = AF_INET;  

serv_addr.sin_addr.s_addr = INADDR_ANY;  

serv_addr.sin_port = htons(portno);      

/* Bind the server info to the listener socket. */

if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)

error("ERROR binding listener socket.");

#ifdef DEBUG

printf("[DEBUG] Listener set.\n");

#endif

/* Return the socket number. */

return sockfd;

}

/* Sets up the client sockets and client connections. */

void get_clients(int lis_sockfd, int * cli_sockfd)

{

socklen_t clilen;

struct sockaddr_in serv_addr, cli_addr;

 

#ifdef DEBUG

printf("[DEBUG] Listening for clients...\n");

#endif

/* Listen for two clients. */

int num_conn = 0;

while(num_conn < 2)

{

/* Listen for clients. */

  listen(lis_sockfd, 253 - player_count);

 

/* Zero out memory for the client information. */

memset(&cli_addr, 0, sizeof(cli_addr));

clilen = sizeof(cli_addr);

 

  /* Accept the connection from the client. */

cli_sockfd[num_conn] = accept(lis_sockfd, (struct sockaddr *) &cli_addr, &clilen);

 

if (cli_sockfd[num_conn] < 0)

/* Horrible things have happened. */

error("ERROR accepting a connection from a client.");

#ifdef DEBUG

printf("[DEBUG] Accepted connection from client %d\n", num_conn);

#endif

 

/* Send the client it's ID. */

write(cli_sockfd[num_conn], &num_conn, sizeof(int));

 

#ifdef DEBUG

printf("[DEBUG] Sent client %d it's ID.\n", num_conn);

#endif

 

/* Increment the player count. */

pthread_mutex_lock(&mutexcount);

player_count++;

printf("Number of players is now %d.\n", player_count);

pthread_mutex_unlock(&mutexcount);

if (num_conn == 0) {

/* Send "HLD" to first client to let the user know the server is waiting on a second client. */

write_client_msg(cli_sockfd[0],"HLD");

 

#ifdef DEBUG

printf("[DEBUG] Told client 0 to hold.\n");

#endif

}

num_conn++;

}

}

/* Gets a move from a client. */

int get_player_move(int cli_sockfd)

{

#ifdef DEBUG

printf("[DEBUG] Getting player move...\n");

#endif

 

/* Tell player to make a move. */

write_client_msg(cli_sockfd, "TRN");

/* Get players move. */

return recv_int(cli_sockfd);

}

/* Checks that a players move is valid. */

int check_move(char board[][3], int move, int player_id)

{

if ((move == 9) || (board[move/3][move%3] == ' ')) { /* Move is valid. */

 

#ifdef DEBUG

printf("[DEBUG] Player %d's move was valid.\n", player_id);

#endif

return 1;

}

else { /* Move is invalid. */

#ifdef DEBUG

printf("[DEBUG] Player %d's move was invalid.\n", player_id);

#endif

return 0;

}

}

/* Updates the board with a new move. */

void update_board(char board[][3], int move, int player_id)

{

board[move/3][move%3] = player_id ? 'X' : 'O';

 

#ifdef DEBUG

printf("[DEBUG] Board updated.\n");

#endif

}

/* Draws the game board to stdout. */

void draw_board(char board[][3])

{

printf(" %c | %c | %c \n", board[0][0], board[0][1], board[0][2]);

printf("-----------\n");

printf(" %c | %c | %c \n", board[1][0], board[1][1], board[1][2]);

printf("-----------\n");

printf(" %c | %c | %c \n", board[2][0], board[2][1], board[2][2]);

}

/* Sends a board update to both clients. */

void send_update(int * cli_sockfd, int move, int player_id)

{

#ifdef DEBUG

printf("[DEBUG] Sending update...\n");

#endif

 

/* Signal an update */

write_clients_msg(cli_sockfd, "UPD");

/* Send the id of the player that made the move. */

write_clients_int(cli_sockfd, player_id);

 

/* Send the move. */

write_clients_int(cli_sockfd, move);

 

#ifdef DEBUG

printf("[DEBUG] Update sent.\n");

#endif

Other Questions
PLwz help thank youuuuuuuuuuuu What is the molar mass of Na(C2 H3 O2)? How did an abundance of natural resources contribute to economic growth in the United States in the late 1800s? ven en herenegou te trasy over vangave at a timeYou can increase your fitness level by overloading a little bit at a time.A. TrueB.False Blood flow The necessity of the normal pattern of blood flow through the heart is graphically illustrated in a pathology known as Transposition of the Great Vessels (TGV). About 4/10,000 infants are born with the congenital heart defect TGV. In this disorder, the origin of the aorta and the pulmonary trunk are switched, however the destinations of these vessels are normal. You may have to do some online research to find a diagram and a description in order to understand this pathology. 1. Select each answer choice that describes the NORMAL sequence of structures through which blood flows, starting with vena cavae. Note that not all structures are listed and that more than one answer may be correct. a. Bicuspid right ventricle aortic valve pulmonary circulation b. Right atrium semilunar valve right ventricle AV valve systemic circulation c. Left atrium bicuspid left ventricle AV valve systemic circulation d. Tricuspid right ventricle pulmonary valve pulmonary circulation Which of the following countries puts the MOST emphasis on ritual and the appropriate way to behave in public and business dealings?Choices: Japan, China, North Korea, South Korea. Shiffon Electronics manufactures music player. Its costing system uses two cost categories, direct materials and conversion costs. Each product must pass through the Assembly Department, the Programming department, and the Testing Department. Direct materials are added at the beginning of the production process. Conversion costs are allocated evenly throughout production. Shiffon Electronics uses weighted-average costing. The following information is available for the month of March 2017 for the Assembly department. Work in process, beginning inventory 340 units Conversion costs (25% complete) Units started during March 860 units Work in process, ending inventory: 140 units Conversion costs (60% complete) The cost details for the month of March are as follows: Work in process, beginning inventory: Direct materials $349,000 Conversion costs $360,000 Direct materials costs added during March $703,500 Conversion costs added during March $1,130,000 What amount of conversion costs is assigned to the ending Work-in-Process account for March HELP ASAP PLEASE!!!Given the figure below, which of the following points name a line segment, a line, or a ray?a. point B and point Cb. point A and point Cc. point D and point Ad. point E and point AU may pick more than one. ______ careers means gathering information about your career choices and weighing the pros and cons of the career. could i get the missing word please I don't know how to do a math problem because I really am really bad at math so I was wondering if somebody can help me and my mom will help me or my dad so I really need your help please help me thank you An automobile traveling 71.0 km/h has tires of 60.0 cm diameter. (a) What is the angular speed of the tires about their axles? (b) If the car is brought to a stop uniformly in 40.0 complete turns of the tires, what is the magnitude of the angular acceleration of the wheels? (c) How far does the car move during the braking? (Note: automobile moves without sliding) If the lessor meets any one of the five Group I criteria, then the lessor classifies the lease as a(n) ________. If the lessor meets both of the Group II criteria, but none of the Group I criteria, then the lessor classifies the lease as a(n) ________. If the transaction does not meet either the Group I or Group II criteria, then the lessor classifies the lease as a(n) ________. Emily purchased a couch, loveseat, in the chair for $2000. The Loveseat cost twice as much as the chair, and the couch cost $600 more than the love seat. Find the cost of the couch, loveseat, and chair. How many grams of sodium bromide must be dissolved in 400.0 g of water to produce a 0.500 molar solution?A20.0 gB52.18C2.00 gD20.6 g Which of the following statements makes an accurate correlation between stages of hominid evolution?a) The brain decreased in size allowing for hominids to use tools. b) The brain increased in size which resulted in hominids developing tools. c) As the brain decreased in size the skull increased in size. d)Language developed as a result of increasing the size of the skull. A cone shaped tepee has a radius of 4 feet and a slant height of 7feet. If joe is six feet tall, determine whether joe is shorter or taller than the height of the tepee. 331 students went on a field trip. six buses were filled and 7 students travled in cars. how many students were in each bus UIME REMAINING02:44:54Rate the following bank accounts from most to least liquid: CD, savings account, checking account, money market accounta CD, savings account, checking account, money market accountb. Savings account, checking account, CD, money market accountCD, money market account, savings account, checking accountd. Checking account, savings account, money market account, CDCPlease select the best answer from the choices providedMark this and retumSave and ExitSubmit If your dream was to become an engineer who designs robots, what steps should you take to get there? Place thefollowing steps in the correct order. Which statement best explains why this text is realistic fiction? A) The story involves a conflict between faith and fitting in. B) The narrator tells the story from the first-person point of view. C) The narrator describes personal feelings about her faith. D) The dialogue reveals the narrators true feelings about life.