Questions
I made the command cp code in c language. But when I copy a file, file...

I made the command cp code in c language. But when I copy a file, file permissions are not copied equally. So I want to copy the file authority as well. What should I do?

#include
#include
#include
#include
#include
#include
#include
#include
#include

int main(int argc, char *argv[])
{
struct stat st;
char ch;
int src, dst;
if(argc != 3)
{
printf("argument error \n");
printf("usage: ./a.out src dest \n");
exit(0);
}
src = open(argv[1], O_RDONLY);
if(src == -1){
perror("open source");
exit(errno);
}
dst = open(argv[2], O_WRONLY | O_CREAT|O_TRUNC, st.st_mode&(S_IRWXU | S_IRWXG | S_IRWXO));
if(dst == -1){
perror("open source");
exit(errno);
}
while(read(src, &ch,1))
write(dst,&ch,1);

close(src);
close(dst);
return 0;
}

In: Computer Science

For this assignment, implement a simple stack calculator which can compute an infix expression. It should...

For this assignment, implement a simple stack calculator which can compute an infix expression. It should take in a string containing an infix expression, compute the result, and print it out. It should handle operators +, -, *, / and parenthesis.

Your program must have two main steps -- first convert the expression to postfix, and then compute the result using the algorithms discussed in class and textbook. These algorithms require that you use a stack. You must implement your own stack, you may not use a library that implements a stack. No credit will be given if you don't implement your own stack.

Although your textbook contains implementations of a stack, I encourage you to try and implement your own stack, using the textbook as a reference if you need it. You can keep your stack simple if you wish -- e.g. it doesn’t need to be templated, it can just hold a simple data type like char. Additionally, it doesn’t need to handle error conditions because we are guaranteed a string containing a syntactically correct infix expression. You may implement either an array-based stack or a link-based stack.

To keep things simple, you may make the following assumptions:

- there are no spaces or other whitespace in the string

- all the operands are single digits

- the result of every operation is a single digit. For example, 2+3 is allowed because the result is 5. 5*3 is not allowed because the result is 15, which is two digits. 5+3+4 is not allowed because even though the first operation is 8, a single digit, the result of the second operation is 12, two digits. 5+3-4 is allowed because the result of the first operation is 8, and the result of the second operation is 4

- any string entered contains a valid, syntactically correct infix expression with balanced parenthesis (if any)

Conversion between int and char

The expression contains both char and int data, because each operator is a char and each operand is a digit. The easiest way to handle this is to implement a stack which supports char data. Since we know all our operands are single digits, we can simply push the character representing the digit onto the stack. Note this character will be the ASCII value of the character, not the integer value! As an example, the character '7' is ASCII value 55, '8' is 56, etc. If you need the actual integer value of the character, in this case 7, there is a convenient way to determine it. You can subtract the ASCII value of zero, '0' from the character. For example,, the following code will store 7 in i:

char c = '7';

int i = c - '0';

To get the character back, you can add '0' to an integer.

Extra Credit

For up to 10% extra credit, modify your program to remove the assumption that the string contains a valid, syntactically correct infix expression. It should compute the value if the string is valid, and gracefully handle an invalid string.

In: Computer Science

Charles (age 38) has just died. He has been credited with the last 30 consecutive credits...

Charles (age 38) has just died. He has been credited with the last 30 consecutive credits of Social Security coverage in the last 30 quarters since he left school and began full-time employment. He had never worked before leaving school. Which of the following persons are eligible to receive Social Security survivor benefits as a result of Charles’s death?

1. Charles’s child, Bill, age 16

2. Charles’s child, Dawn, age 19

3. Charles’s widow, Maggie, age 38

4. Charles’s dependent mother, Betty, age 60

Group of answer choices

1 only

1, 2 and 4

1 and 2

2, 3 and 4

In: Finance

How does the use of a learning management system better link training to business strategy and...

How does the use of a learning management system better link training to business strategy and goals?

i need about 150 words please. thx

In: Operations Management

While death maybe an unfortunate and inevitable occurrence in human life, the death of government policies...

While death maybe an unfortunate and inevitable occurrence in human life, the death of government policies was originally thought of as so or near impossible. Many researchers considered that termination can cause difficulties when trying to identify causal and predictable relationships. Possibly even more troublesome is the misunderstanding of what constitutes termination (Kinney, N, 2013).

However, the government of Malaysia have terminated several policies such as Teaching Science and Mathematics in English (PPSMI), Goods and Services Taxes (GST) and bend bridge project.

  1. Based on the examples given above, do you agree with the author? Justify your answer

  2. If you were hired as a public official and you were given instructions to terminate a program or a policy,

    1. i) how would you proceed?

    2. ii) would you apply the ‘big bang’ or the long whimper approach? Justify your answer?

In: Operations Management

Richard, barry and Andrew decided to enter into a partnership agreement as from 1st July 2018,...

Richard, barry and Andrew decided to enter into a partnership agreement as from 1st July 2018, some of the provisions of which were as follows.

  1. Richard to contribute $24000 cash, inventory the fair value of which was $51000, plant and machinery $94320, accounts receivable totalling $15240
  2. Barry to contribute $45000 cash and act as manager for the business at an annual salary of $38400 to be allocated to him at the end of each year.
  3. Andrew to contribute $19800 cash, land $144000, premises $288000, furniture and fittings $48600, and motor vehicles $37800. A mortgage of $216000 secured over the premises was outstanding and the partnership agreed to assume the mortgage.
  4. Profits or losses of the firm to be divided between or borne by Richard, barry and Andrew in the proportion of 2:1:3 respectively.
  5. Interest to be allowed at 8% p.a. on the capital contribution by the partners. Interest at 10% p.a. to be charged on partners’ drawings.
  6. During the year ended 30 June 2019, the income of the partnership totaled $144960, and the expenses (excluding interest on capital and drawings and Barry’s salary) amounted to $51600.
  7. Richard withdrew $14400 on 1 October 2018 and $9600 on 1 January 2019; Barrie withdrew $4800 only on 1 April 2019; Andrew withdrew $12000 on 30 June 2019.

Required

Prepare general journal entries necessary to open the records of the partnership.

Prepare the balance sheet of the partnership immediately after formation.

Prepare a Profit Distribution account for the year ended 30 June 2019.

In: Accounting

A 5kg object starts off at ? = 0 travelling at ?x= +10m/s .  During its motion,...

A 5kg object starts off at ? = 0 travelling at ?x= +10m/s .  During its motion, it is subject to a position-dependent force given by:

?net(?) = +480 + 2 ≤ ? ≤ 4,

−120?  + 4 ≤ ? ≤ 6,

0 ??ℎ??????

When the object arrives at ? = +4? (parts a-b):

a. Calculate the work done on the object.

b. Calculate the speed of the object.

When the object arrives at ? = +8? (parts c-e):

c. Calculate the total net work done on the object up until this point.

d. Calculate the speed of the object

e. Suppose the net force between +4 ≤ ? ≤ 6 is entirely due to a non-conservative force (and all other forces are

conservative), how much total mechanical energy is lost to the environment during the whole trip?

In: Physics

which is a correct example of energy coupling using ATP? Please choose the correct answer A....

which is a correct example of energy coupling using ATP? Please choose the correct answer

A. The electron transport chain uses ATP to pump protons against their electrochemical gradient.

B. Hydrolyzing ATP to drive an anabolic reaction.

C. Substrate level phosphorylation makes ATP.

D. In photosynthesis, light energy is trapped into an ATP molecule.

In: Biology

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

Answer the following parts by describing how the different retailers could use the area listed to...

Answer the following parts by describing how the different retailers could use the area listed to enhance the store’s image and atmosphere. a. Drugstore’s entrance b. Music Store’s windows c. Restaurant’s cash wrap

In: Operations Management

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