Questions
Use the following code fragment: 1       sub x4,x4,x0      2       add x3,x4,x0      3       sub x6,x3,x2...

Use the following code fragment:

1       sub x4,x4,x0

     2       add x3,x4,x0

     3       sub x6,x3,x2

     4       mul x1,x6,x7

     5       add x2,x5,x9

     6       div x5,x9,x2

     7       add x8,x1,x4

Draw the dependency graph among the instructions and indicate the type of data hazards (such as RAW, WAW, etc.) on each edge.

In: Computer Science

write a c++ program to perform the following operations on stack of Integers (Array Implementation of...

write a c++ program to perform the following operations on stack of Integers (Array Implementation of Stack with maximum size MAX)

(i) Push an Element on to stack

(ii) Pop an Element from stack

(iii) Demonstrate how stack can be used to check Palindrome

(iv) Display the status of stack

(v) Exit

In: Computer Science

4. Please name your driver program XXX_P04 where XXX are your initials. Given the array inputArray...

4. Please name your driver program XXX_P04 where XXX are your initials. Given the array inputArray (doubles), write a method called swap which will swap any two contiguous (next to each other) elements. Swap will be passed two parameters, the index of the first element to be swapped and the array name. Write another method printArray that will print the array 5 elements to a line. PrintArray will be passed one parameter the array name. See the videos for help with this. The array elements are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.

Java Eclipse

In: Computer Science

Q1. [10 pt] How will you implement a binary semaphore with block wake-up protocol? Give the...

Q1. [10 pt] How will you implement a binary semaphore with block wake-up protocol? Give the code.

(Please help, Operating system question, 2011 Spring)

In: Computer Science

Create a project with a Program class and write the following two methods (headers provided) as...

Create a project with a Program class and write the following two methods (headers provided) as described below:

  1. A Method, public static int InputValue(int min, int max), to input an integer number that is between (inclusive) the range of a lower bound and an upper bound. The method should accept the lower bound and the upper bound as two parameters and allow users to re-enter the number if the number is not in the range or a non-numeric value was entered.
  2. A Method, public static bool IsValid(string id), to check if an input string satisfies the following conditions: the string’s length is 5, the string starts with 2 uppercase characters and ends with 3 digits. For example, “AS122” is a valid string, “As123” or “AS1234” are not valid strings.

In: Computer Science

Can anyone who is knowledgable with multi-threading take a look at the following c++ program posted...

Can anyone who is knowledgable with multi-threading take a look at the following c++ program posted below and take a swing at making it multi-threaded (and if possible please use C++ 2011 standard threading). Its only one part of the overall program, so there wont be anything to compile/test but if you could take a crack at it that would be great. Even if it doesnt work when I test your program, ill still give credit/like since then ill at least have somewhere to start and a better understanding of what needs to be done from your code. If you have any specific questions please and ill do my best to answer them, thank you!


scan1.cpp
/*
* This program takes the name of a password file and some guessing parameters
* and tries to guess the passwords by simple enumeration. Command line
* is the
* filename charset short long
* Where charset is either a string of characters from which the password
* is drawn, or one of these special names:
* ASCII Printable ascii, 32-126
* DIGITS 0-9
* ALNUM Alphanumeric characters, 0-9A-Za-z
* Short and long are range of lengths of the passwords to try.
*/

#include <crypt.h>
#include <errno.h>

#include <cstring>
#include <cstdlib>

#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <list>
#include <memory>

#include "enum.h"

using std::string;

/*
* Try the indicated password against each recorded password in the file.
* Return true if any matched, false otw.
*/
bool scan(const std::list<std::pair<string,string>> &passwords, string pass)
{
struct crypt_data pass_data; // Password data area.
string line; // Input line.
bool found = false; // We found something.

// Clear the data area.
memset(&pass_data, 0, sizeof pass_data);

// Try each of the passwords.
for(auto p: passwords) {
// Encrypt the guess using the method recorded for the existing.
// (crypt_r only reads the encryption type and salt from the
// exiting password, not the hash itself.)
char *ret = crypt_r(pass.c_str(), p.second.c_str(), &pass_data);

// See if we got a match.
if(ret && ret == p.second) {
std::cout << p.first << ": " << pass << std::endl;
found = true;
}
}
return found;
}

int main(int argc, char **argv)
{
// Check args.
if(argc != 5) {
std::cerr << "Usage: " << argv[0]
<< " filename charset min max" << std::endl;
std::cerr << " charset is DIGITS, ALNUM, ASCII or a set of "
<< "characters." << std::endl;
exit(1);
}

// Size range.
int min = atoi(argv[3]);
int max = atoi(argv[4]);

// Create an appropriate enumerator object.
std::unique_ptr<pwd_enum> enumerator;
string charset = argv[2];
if(charset == "DIGITS") {
enumerator.reset(new pwd_enum('0', '9', min, max));
} else if(charset == "ALNUM") {
enumerator.reset
(new pwd_enum("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz", min, max));
} else if(charset == "ASCII") {
enumerator.reset(new pwd_enum(' ', '~', min, max));
} else {
enumerator.reset(new pwd_enum(charset, min, max));
}

// Try to open the file.
std::ifstream passfile(argv[1], std::fstream::binary);
if(!passfile) {
std::cerr << "Unable to open " << argv[1] << std::endl;
exit(1);
}

// Read the passwords from the file.
std::list<std::pair<string,string>> passwords;
string line;
while(std::getline(passfile, line)) {
// Extract account
int loc = line.find(":");
if(loc == string::npos) continue;
string acct = line.substr(0,loc);

// Extract crypted password, leaving it in line.
line.erase(0,loc+1);
loc = line.find(":");
if(loc != string::npos) {
acct.erase(loc);
}

// Add the account and password to the list.
passwords.push_back(std::make_pair(acct, line));
}

// This will happen at the end anyway, but we're going to spend a
// long time in the next loop, so let's release the resource now.
passfile.close();

// Run through the passwords.
string pw;
bool found = false;
while((pw = enumerator->next()) != "") {
found = scan(passwords, pw) || found;
//std::cout << pw << std::endl;
}
if(!found)
std::cout << "No passwords matched." << std::endl;
}

.

In: Computer Science

Python Write a function str_slice(s) to slice sentence into single word by their spaces and punctuations...

Python
Write a function str_slice(s) to slice sentence into single word by their spaces and punctuations and returns a list.
You cannot use split(), join() method for this define function
Example:
>>>str_slice(‘Hi, I like it!!’)
[‘Hi’, ‘, ’, 'I', ‘ ‘, ‘like’, ‘ ‘, ‘it’, ‘!!’]

In: Computer Science

This program has to be written in assembly language using emu8086. Please choose the .EXE template....

This program has to be written in assembly language using emu8086. Please choose the .EXE template. The requirements and the action is contained in the docx file.

You’ve been hired by Spacely Sprockets and they need to be able to write order information out to a file. Using all of the knowledge that we’ve gained in the last few sections on structures and files, you need to write a program that does the following:

  1. Design a structure that can hold an order number (integer type data), a customer’s ID (integer type data), a sprocket type (string type data), a part quantity (integer type data) and an order total (floating point data). These will be simply stored in the structure as string data.
  2. When your program is run, prompt the user to enter each of these pieces of data into the structure.
  3. Once the last piece of structure data has been entered, prove the structure is working correctly by neatly printing the structure’s contents out to the screen.
  4. Open a file up for writing and write the structure out to the file. Print a message out to the screen once the file has been created.
  5. Clear any data in the structure out.
  6. Open the file back up for reading and pull the data back into the structure.
  7. Print the structure out to the screen again. If you are successful, the same data should appear twice on the screen (once from the filling\printing of the structure and the second time from reading the structure in from a file.

Here’s a sample run:

Order Number: 105

Customer ID: 405

Sprocket Type: Awesome Atomic Sprocket

Part Quantity: 3

Order Total: 105.74

Struct written to file C:\asm\test.txt

Order Number: 105

Customer ID: 405

Sprocket Type: Awesome Atomic Sprocket

Part Quantity: 3

Order Total: 105.74

Program Complete!

Hints: Think procedures! You can simplify the code and your debugging life by writing procedures. For example, a print structure routine, a save to file routine, a read from file routine, et cetera. Secondly, DO NOT code this application in a single shot – incrementally build up each piece of logic otherwise you will get lost when things don’t work right.

In: Computer Science

/* Test#1: Please type 0 for the Fibonacci sequence Please type 1 for the Fibonacci square...

/*
Test#1:

Please type 0 for the Fibonacci sequence 
Please type 1 for the Fibonacci square matrix 
Please type 2 for the flipped Fibonacci square matrix based on Y-axis 
Please type 3 for the flipped Fibonacci square matrix based on X-axis 
0
Please enter size for the Fibonacci sequence (size <100)Â 
10
0 1 1 2 3 5 8 13 21 34Â 
Median of the Fibonacci sequence is 4.000000

Test#2:

Please type 0 for the Fibonacci sequence 
Please type 1 for the Fibonacci square matrix 
Please type 2 for the flipped Fibonacci square matrix based on Y-axis 
Please type 3 for the flipped Fibonacci square matrix based on X-axis 
1
Please enter length of edge for the Fibonacci matrix (size <10)Â 
4
The matrix is 
0 1 1 2Â 
3 5 8 13Â 
21 34 55 89Â 
144 233 377 610Â 

Test#3:

Please type 0 for the Fibonacci sequence 
Please type 1 for the Fibonacci square matrix 
Please type 2 for the flipped Fibonacci square matrix based on Y-axis 
Please type 3 for the flipped Fibonacci square matrix based on X-axis 
2
Please enter length of edge for the Fibonacci matrix (size <10)Â 
4
The matrix is 
2 1 1 0Â 
13 8 5 3Â 
89 55 34 21Â 
610 377 233 144Â 

Test#4:

Please type 0 for the Fibonacci sequence 
Please type 1 for the Fibonacci square matrix 
Please type 2 for the flipped Fibonacci square matrix based on Y-axis 
Please type 3 for the flipped Fibonacci square matrix based on X-axis 
3
Please enter length of edge for the Fibonacci matrix (size <10)Â 
4
The matrix is 
144 233 377 610Â 
21 34 55 89Â 
3 5 8 13Â 
0 1 1 2Â 

Of course, your program cannot just satisfy above four test cases. 
It should be generalized to satisfy any Fibonacci sequence (size <100) and Fibonacci Matrix (< 10x10).

*/

#include <stdio.h>
//@Hint: put the function you need here


int main() {
   int a[100]; //For Fibonacci sequence
   int fibonacciMatrix[10][10]; //For Fibonacci Matrix
   int num = 0;
   float median = 0.0; //Median number of the Fibonacci sequence
   int choice = 0;
   int lengthFbSequence = 0; //the length of Fibonacci sequence
   int lengthFbMatrix = 0; //the length of the edge of Fibonacci Matrix

   printf("Please type 0 for the Fibonacci sequence \n");
   printf("Please type 1 for the Fibonacci square matrix \n");
   printf("Please type 2 for the flipped Fibonacci square matrix based on Y-axis \n");
   printf("Please type 3 for the flipped Fibonacci square matrix based on X-axis \n");
   scanf("%d", &choice);

   while (choice < 0) {
        printf("Please type 0 for the Fibonacci sequence \n");
        printf("Please type 1 for the Fibonacci matrix \n");
        printf("Please type 2 for the flipped Fibonacci square matrix based on Y-axis \n");
        printf("Please type 3 for the flipped Fibonacci square matrix based on X-axis \n");
        scanf("%d", &choice);
   }
   
   if (choice == 0) {
      printf("Please enter size for the Fibonacci sequence (size <100) \n");
      scanf("%d", &lengthFbSequence);
      while (lengthFbSequence < 0) {
            printf("Please enter size for the Fibonacci sequence (size <100) \n");
            scanf("%d", &lengthFbSequence);         
      }
      //@Hint: Please start to code for option 0



   }
   
   if (choice == 1 || choice == 2 || choice == 3) {
      printf("Please enter length of edge for the Fibonacci matrix (size <10) \n");
      scanf("%d", &lengthFbMatrix);
      while (lengthFbMatrix < 0) {
            printf("Please enter length of edge for the Fibonacci matrix (size <10) \n");
            scanf("%d", &lengthFbMatrix);         
      }
       //@Hint: Please start to code for option 1, 2, 3



   }
   
   return 0;
}

In: Computer Science

acos() Prototype double acos(double x); To find arc cosine of type int, float or long double,...

acos() Prototype

double acos(double x);

To find arc cosine of type int, float or long double, you can explicitly convert the type to double using cast operator.

 int x = 0;
 double result;
 result = acos(double(x));
 int x = 0;
 double result;
 result = acos(double(x));

acos() Parameter

The acos() function takes a single argument in the range of [-1, +1]. It's because the value of cosine is in the range of 1 and -1.

Parameter Description
double value Required. A double value between - 1 and +1 inclusive.

acos() Return Value

The acos() functions returns the value in range of [0.0, π] in radians. If the parameter passed to the acos() function is less than -1 or greater than 1, the function returns NaN (not a number).

Parameter (x) Return Value
x = [-1, +1] [0, π] in radians
-1 > x or x > 1 NaN (not a number)

Example 1: acos() function with different parameters

#include <stdio.h>
#include <math.h>

int main() {
    // constant PI is defined
    const double PI =  3.1415926;
    double x, result;

    x =  -0.5;
    result = acos(x);
    printf("Inverse of cos(%.2f) = %.2lf in radians\n", x, result);

    // converting radians to degree
    result = acos(x)*180/PI;
    printf("Inverse of cos(%.2f) = %.2lf in degrees\n", x, result);

    // paramter not in range
    x = 1.2;
    result = acos(x);
    printf("Inverse of cos(%.2f) = %.2lf", x, result);

    return 0;
}

Output

Inverse of cos(-0.50) = 2.09 in radians
Inverse of cos(-0.50) = 120.00 in degrees
Inverse of cos(1.20) = nan

give an example of (math.h) function from the c language library and explain

1- prototype

2-input type (parameters)

3-output or return type

4- number of arguments/parameters

5- example

In: Computer Science

This assignment involves developing a program that prompts the user to enter a series of 10...

This assignment involves developing a program that prompts the user to enter a series of 10 integers and then determines and displays the largest and smallest values entered.

Your solution must use at least the following variables: counter: A counter to count how many integers were entered

a Number: The integer most recently input by the user,

smallest: The smallest number entered so far, largest: The largest number entered so far.

Write three separate programs for this assignment:

Name the first program HiLoWhile and use a while construct in the solution.

Name the second program HiLoFor and use a for construct in the solution.

Name the third program HiLoDoWhile and use a do-while construct in the solution.

Write the pseudocode for ONLY the HiLoWhile program.

IN JAVA

In: Computer Science

Many dog owners see the benefit of buying natural dog food and treats. Dog Day Afternoon...

Many dog owners see the benefit of buying natural dog food and treats. Dog Day Afternoon is a local company that creates its own dog food and treats. Their products are made locally and with natural ingredients. Sales are up and the owners of Dog Day Afternoon have decided to expand their business. Currently they are manually calculating sales. They need a computer program to help speed up the process.

The owners of Dog Day Afternoon decided to get some help. They approached the Career Center and posted numerous temporary programming positions. You are eager to get some experience as a programmer so you apply and get the job.

Your portion of the project is to create a class called DogDay that will take in the quantity and the size of the dog treat. Store these values in attributes called quantity (integer) and size (string). The class will also contain three methods. One method will determine the cost of one dog bone. Name this method DeterminePrice. The cost of the different size natural raw hide bones is as follows:

  • Size A = $2.29
  • Size B = $3.50
  • Size C = $4.95
  • Size D = $7.00
  • Size E = $9.95

Store the cost of each individual dog bone in an attribute called price.

Your second method will be called DetermineTotal. This method will calculate the total cost (quantity * cost) and round this value to 2 decimal places. It will store this value in an attribute called total.

Your final method will return the total.

When creating this class start coding in VS Code or IDLE. To test your class create an object. Send in the values 6 and C. Next call your method DeterminePrice followed by DetermineTotal. Finally print the method ReturnTotal to the screen. Your code should print the following: 29.7

In: Computer Science

Suppose internet data in hex is 99 f5 44 27 23 96 e3 4f. Calculate internet...

Suppose internet data in hex is 99 f5 44 27 23 96 e3 4f. Calculate internet checksum.

You need to show steps and write answer here

In: Computer Science

You will conduct a systems analysis project ( car rentals ) by performing 3 phases of...

You will conduct a systems analysis project ( car rentals ) by performing 3 phases of SDLC (planning, analysis and design) for a small (real or imaginary) organization. ( car rentals )The actual project implementation is not required (i.e. No coding required.)

This project should follow the main steps of the first three phases of the SDLC (phase 1, 2 and 3). Details description and diagrams should be included in each phase.

my part that i need help in it :

, you are required to determine the main business requirements; consequently, the following must be included:

  • List the functional and nonfunctional business requirements for the system. (1 mark)
  • Create Use Cases(1 mark)
  • Model Processes (Data Flow Diagramming)(1 mark)
  • Model data (ER modeling)(1 mark)

In: Computer Science

Database systems and Information systems An information system performs three sets of services: It provides for...

Database systems and Information systems

An information system performs three sets of services:

  • It provides for data collection, storage, and retrieval.
  • It facilitates the transformation of data into information.
  • It provides the tools and conditions to manage both data and information.

Basically, a database is a fact (data) repository that serves an information system. If the database is designed poorly, one can hardly expect that the data/information transformation will be successful, nor is it reasonable to expect efficient and capable management of data and information.

The transformation of data into information is accomplished through application programs. It is impossible to produce good information from poor data; and, no matter how sophisticated the application programs are, it is impossible to use good application programs to overcome the effects of bad database design. In short: Good database design is the foundation of a successful information system.

Database design must yield a database that:

  • Does not fall prey to uncontrolled data duplication, thus preventing data anomalies and the attendant lack of data integrity.
  • Is efficient in its provision of data access.
  • Serves the needs of the information system.

The last point deserves emphasis: even the best-designed database lacks value if it fails to meet information system objectives. In short, good database designers must pay close attention to the information system requirements.

Systems design and database design are usually tightly intertwined and are often performed in parallel. Therefore, database and systems designers must cooperate and coordinate to yield the best possible information system.  

The SDLC traces the history (life cycle) of an information system. The DBLC traces the history (life cycle) of a database system. Since we know that the database serves the information system, it is not surprising that the two life cycles conform to the same basic phases.

There are two basic approaches to database design: top‑down and bottom‑up.

Top‑down design begins by identifying the different entity types and the definition of each entity's attributes. In other words, top‑down design:

  • starts by defining the required data sets and then
  • defines the data elements for each of those data sets.

Bottom‑up design:

  • first defines the required attributes and then
  • groups the attributes to form entities.

Although the two methodologies tend to be complementary, database designers who deal with small databases with relatively few entities, attributes, and transactions tend to emphasize the bottom‑up approach. Database designers who deal with large, complex databases usually find that a primarily top‑down design approach is more appropriate.

Even if a generally top‑down approach is selected, the normalization process that revises existing table structures is (inevitably) a bottom‑up technique. E-R models constitute a top-down process even if the selection of attributes and entities may be described as bottom-up. Since both the E-R model and normalization techniques form the basis for most designs, the top‑down vs. bottom-up debate may be based on a distinction without a difference.  

Assignment

Write two to three paragraphs answering each of the following questions:

  • What are business rules? Why are they important to a database designer?
  • What is the data dictionary's function in database design?
  • What factors are important in a DBMS software selection?

In: Computer Science