Questions
How can i bubble sort a sentence in a char array in c++ This is the...

How can i bubble sort a sentence in a char array in c++

This is the prototype of the function:

char* sort(char string[], int numOfWords, int lengthOfWord);

This is the testing code in the main file:

char words[] = "CAT FAT BAT HAT RAT";
printf("Before sort: t%s\n";words);
char result = sort(words; 5; 3);
printf("After sort : t%s\n"; result);

Expected output:

Before sort: CAT FAT BAT HAT RAT
After sort: BAT CAT FAT HAT RAT

In: Computer Science

Write a MIPS assembly program that calculates the sum of all the elements in the following...

Write a MIPS assembly program that calculates the sum of all the elements in the following array: int array[10]={12,21,3,40,15,6,17,8,29,10}

In: Computer Science

create a program in java that will evaluate a logical expression (compound proposition) based on the...

create a program in java that will evaluate a logical expression (compound proposition) based on the given truth values of individual propositional variables. The logical expression may include the logical AND or the logical OR operators. The NOT operator will be included in the variable names itself. So, a proposition such as ¬a would appear as na in the logical expression.

Here is an example of a logical expression using proper notation:

a ∧ b ∨ ¬c ∨ d

This expression will be represented as the following in this program to accommodate simple keyboard input:

a and b or nc or d

The logical operators will be evaluated left to right. Parentheses will not be included.

input the following information:

• number of variables in an expression, between 2 and 5

• the truth values of each of these variables

• a logical expression involving these variables, their negated counterparts and the logical operators and/or

In: Computer Science

List and discuss two key differences between class diagrams in analysis and those in design. What...

List and discuss two key differences between class diagrams in analysis and those in design. What are some factors that need to be considered in determining an appropriate design pattern to utilize? Please identify at least 3-4 factors and elaborate on why these factors are important.

In: Computer Science

A marketing survey looked at the preferences of hot drink size among 1275 random customers of...

A marketing survey looked at the preferences of hot drink size among 1275 random
customers of a coffee shop chain. The survey was also interested in whether the customer’s gender
affects their preference. The results of the survey were used to estimate the probabilities in this joint
probability distribution:
Tall (T) Grande (G) Venti (V)
Female (F) 0.12 0.24 0.06
Male (M)    0.08 0.38    0.12


a) What is p (M, T), the joint probability that a customer in the survey was both male and prefers tall
drinks?
b) What is p (F), the marginal probability that a customer in the survey was female?
c) What is p(G), the marginal probability that a customer in the survey prefers Grande drinks?
d) What is p (V | M), the conditional probability, given a customer in the survey was male, that he prefers
venti drinks?
e) What is p (F | V), the conditional probability, given a customer in the survey prefers venti drinks, that the customer was female?
f) There are two random variables in this situation, drink size and gender. Are they independent or dependent? Explain how you arrived at the answer and show your calculations.

In: Computer Science

Develop a program Grades.java that collects the user's (students) name, course name, and the score for...

Develop a program Grades.java that collects the user's (students) name, course name, and the score for three quizzes. You are supposed to read this data from the keyboard using the Scanner class. Calculate the total score and the average score.

Further, using the grading scale below, based on the average score computed above, your program should calculate and output a letter grade. and the range boundaries should be configured properly (i.e.: exactly 90 and above is an A, and anything less than 90 to exactly 80 is a B). The grading scale to use is as follows:

Letter Category

Average Score Range

A 90 - 100
B 80 - 90
C 70 - 80
D 60 - 70
E 0 - 60

Note: The E Category is not a typo.

Declare the variables in the order studName, courseName, scoreQuiz_1, scoreQuiz_2, and scoreQuiz_3, totalScore, averageScore, and letterCategory. Make sure you declare the variables studName, courseName, and letterEvaluation as String class variables. Select proper data type for the variables totalScore and averageScore. The data type should support decimals. Use a constant variable NUM_OF_Quizzes to compute the average score.

Things to watch for: As you are determining your logic for your if statements in this project, consider that a percentage of 90.0 results in an A, 89.8 results in a B category, 79.12 results in a C category, and 69.994949 results in a D category. That last example is a bit extreme, but the idea is to not try to predict how many 9s after the decimal you need to account for. Just think of where the last boundary ends and where the next one begins, and how you might use your mathematical operators to account for that (is it less-than-or-equal-to, or just less than?).

Formatting: Import the package DecimalFormat to format the average score data. You do this by typing: import java.text.DecimalFormat; either below or above the line: import java.util.Scanner;

Then create a DecimalFormat object by typing: DecimalFormat df = new DecimalFormat("##.00"); either above or below the line Scanner scnr = new Scanner(System.in);

A format with 2 digits would be displayed by using the df as follows:

System.out.println("The average score is: "+df.format(averageScore));

Pseudocode: Prior to writing the Java code for the project, develop a document in pseudocode that outlines how the program will flow. Remember that there are no specific rules regarding pseudocode, but rather you should write pseudocode in a way that is human-readable and understandable (English for this assignment).

The following example is what your program might look like:

____________________________________________________________________________________

Your Score Card for Three Quizzes

Please enter your name : Julie Kimbal

Please enter your course you are taking : CS1400 Fundamentals of Programming

Please enter the score for quiz 1 : 77

Please enter the score for quiz 2 : 85

Please enter the score for quiz 3 : 79

The total score is 241.0

The average score is : 80.33

Thanks Julie Kimbal. Your grade for the 3 quizzes in CS1400 Fundamentals of Programming is a (n) B.

________________________________________________________________________________________________________________________

Experiment cases: Make sure that your program computes correct average scores for the following experiment cases:

Quiz 1 Quiz 2 Quiz 3 Average Category
Experiment case 1 67 58 54 59.67 E
Experiment case 2 78 71 83 77.33 C
Experiment case 3 89 90 93 90.67 A

You need to upload three files:

  1. attach a screenshot of one output
  2. pseudocode document
  3. java file (not the class file) Grades.java

In: Computer Science

Software testing occurs near the end of the programming process. Because of this, if a project...

Software testing occurs near the end of the programming process. Because of this, if a project falls behind schedule, testing time is often reduced. Discuss the possible impacts of less-than-thorough testing. Topics might include company reputation, customer dissatisfaction, the company’s ability to sell new or updated products, etc. Discuss which is worse: releasing a product late or releasing it on time without fully testing it. "please answer based on arguments"

In: Computer Science

Under certain circumstances, an organization may choose to have their Windows 2016 server become a RADIUS...

Under certain circumstances, an organization may choose to have their Windows 2016 server become a RADIUS server. What are the major functions NPS provides for RADIUS clients, and what effect does it have on the overall security of remote access?

Your post should be 250-500 words.

In: Computer Science

The following code must be written using matlab Create a contour plot of the following function...

The following code must be written using matlab

Create a contour plot of the following function f(x,y) = (x+y^2-10)^2 +(x^2+y^2+8) in range [-6,6] for both x and y

Clearly indicate in the plot the coordinates of the minimum ponts and the the corresponding function values in these points

In: Computer Science

hpw do a put the program to halt, placing a limit greater than 1 on the...

hpw do a put the program to halt, placing a limit greater than 1 on the eating state for each philosopher in the program below?







#include <pthread.h>
#include <semaphore.h>
#include <stdio.h>
#include <unistd.h>


#define N 5
#define THINKING 2
#define HUNGRY 1
#define EATING 0
#define LEFT (phnum + 4) % N
#define RIGHT (phnum + 1) % N
#define deprecated

int state[N];
int phil[N] = { 0, 1, 2, 3, 4 };

sem_t mutex;
sem_t S[N];

void test(int phnum)
{
if (state[phnum] == HUNGRY
&& state[LEFT] != EATING
&& state[RIGHT] != EATING) {
// state that eating
state[phnum] = EATING;

sleep(2);

printf("Philosopher %d takes fork %d and %d\n",
phnum + 1, LEFT + 1, phnum + 1);

printf("Philosopher %d is Eating\n", phnum + 1);

// sem_post(&S[phnum]) has no effect
// during takefork
// used to wake up hungry philosophers
// during putfork
sem_post(&S[phnum]);
}
}

// take up chopsticks
void take_fork(int phnum)
{

sem_wait(&mutex);

// state that hungry
state[phnum] = HUNGRY;

printf("Philosopher %d is Hungry\n", phnum + 1);

// eat if neighbours are not eating
test(phnum);

sem_post(&mutex);

// if unable to eat wait to be signalled
sem_wait(&S[phnum]);

sleep(1);
}

// put down chopsticks
void put_fork(int phnum)

{

sem_wait(&mutex);

// state that thinking

state[phnum] = THINKING;

printf("Philosopher %d putting fork %d and %d down\n",

phnum + 1, LEFT + 1, phnum + 1);

printf("Philosopher %d is thinking\n", phnum + 1);

if(phnum==N-1){ // this is the last philosopher for which we reverse the order of checking it will first check right then left

test(RIGHT);

test(LEFT);

}

else{ // this is for the remaining philosopher for which the order of checking will be first check left then right

test(LEFT);

test(RIGHT);

}

sem_post(&mutex);

}

void* philospher(void* num)
{

while (1) {

int* i = num;

sleep(1);

take_fork(*i);

sleep(0);

put_fork(*i);
}
}

int main()
{

int i;
pthread_t thread_id[N];

// initialize the semaphores
sem_init(&mutex, 0, 1);

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

sem_init(&S[i], 0, 0);

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

// create philosopher processes
pthread_create(&thread_id[i], NULL,
philospher, &phil[i]);

printf("Philosopher %d is thinking\n", i + 1);
}

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

pthread_join(thread_id[i], NULL);
}

In: Computer Science

What are the strengths of sequence diagrams? In your main post, select an appropriate scenario and...

What are the strengths of sequence diagrams? In your main post, select an appropriate scenario and identify why a sequence diagram can provide appropriate insight to solve the scenario. What are factors that would affect the workflow of the outlined sequence diagram to solve this given scenario? Please be sure to provide specific scenarios to address the strengths of sequence diagrams.

In: Computer Science

Using Perl create a program that will output the scores of 3 golfers that are playing...

Using Perl create a program that will output the scores of 3 golfers that are playing nine holes of golf.
Create a blank array, this will be a two-dimensional array
@golf_array;
Load up the follow scores
For hole 1: Golfer 1 shot 4, Golfer 2 shot 3, Golfer 3 shot 5
For hole 2: Golfer 1 shot 3, Golfer 2 shot 3, Golfer 3 shot 4
For hole 3: Golfer 1 shot 7, Golfer 2 shot 5, Golfer 3 shot 5
For hole 4: Golfer 1 shot 6, Golfer 2 shot 3, Golfer 3 shot 4
For hole 5: Golfer 1 shot 3, Golfer 2 shot 7, Golfer 3 shot 4
For hole 6: Golfer 1 shot 3, Golfer 2 shot 3, Golfer 3 shot 3
For hole 7: Golfer 1 shot 4, Golfer 2 shot 4, Golfer 3 shot 5
For hole 8: Golfer 1 shot 5, Golfer 2 shot 5, Golfer 3 shot 4
For hole 9: Golfer 1 shot 3, Golfer 2 shot 6, Golfer 3 shot 3
Print out the scores for each golfer
Golfer 1:
Hole 1 – 4
Hole 2 – 3

Hole 9 – 3
Golfer 2:
Hole 1 – 3
Hole 2 – 3

Extra credit:
Print out which golfer had the lowest score and what that score was.

In: Computer Science

This question is all about Java 1. If we need to import multiple classes from different...

This question is all about Java

1. If we need to import multiple classes from different packages do we need an import line for each? Why?

2. How does dot notation differ when invoking methods & importing packages?

3. How does * work when importing packages?

4. We have to import the Scanner class in order to use its methods. Why not for String or System or Math class?

5. What package are each of the classes found in?

6. We need an object to invoke (call) the String & Scanner methods. Why don't we need to instantiate an object to invoke the Math methods?

7. List the Math methods & their parameter

In: Computer Science

What is a content delivery network, and what are the advantages and disadvantages of using a...

What is a content delivery network, and what are the advantages and disadvantages of using a content delivery network. When do you think you should and should not use one, and why?

In: Computer Science

In Python. Create a function called predictKNN(). Your function will return the classification of your data-pointIn...

In Python. Create a function called predictKNN(). Your function will return the classification of your data-pointIn addition to any parameters you see fit, your function should accept:

  • k
  • a data-point: a vector of r numbers
  • a dataframe with r columns.
    Run your function at least 5 times with different parameters.

In: Computer Science