Questions
Write a program called distance_square.c that reads an integer n from standard input, and prints an...

Write a program called distance_square.c that reads an integer n from standard input, and prints an nxn pattern of integers. Each integer is the minimum number of steps required to reach the centre of the square. Steps can only be up, down, left or right (no diagonal movement). the question should be allowed to use only while loop

 4  3  2  3  4 
 3  2  1  2  3 
 2  1  0  1  2 
 3  2  1  2  3 
 4  3  2  3  4 

Observing the example above, each integer represents the minimum number of steps required to reach the centre of the square. For example, the top left corner contains the integer 4. The centre of the square can be reached in 4 steps (right, right, down, down).

You can assume n is odd and >= 3.

Make your program match the examples below exactly.

This exercise is designed to give you practice with while loops, if statements and some mathematical operators. Do not use arrays for this exercise!

Note: you are not permitted to use an array in this exercise. and you are suppose to use while loop only!!

./distance_square
Enter square size: 3
 2  1  2 
 1  0  1 
 2  1  2 

./distance_square
Enter square size: 9
 8  7  6  5  4  5  6  7  8 
 7  6  5  4  3  4  5  6  7 
 6  5  4  3  2  3  4  5  6 
 5  4  3  2  1  2  3  4  5 
 4  3  2  1  0  1  2  3  4 
 5  4  3  2  1  2  3  4  5 
 6  5  4  3  2  3  4  5  6 
 7  6  5  4  3  4  5  6  7 
 8  7  6  5  4  5  6  7  8 

./distance_square
Enter square size: 15
14 13 12 11 10  9  8  7  8  9 10 11 12 13 14 
13 12 11 10  9  8  7  6  7  8  9 10 11 12 13 
12 11 10  9  8  7  6  5  6  7  8  9 10 11 12 
11 10  9  8  7  6  5  4  5  6  7  8  9 10 11 
10  9  8  7  6  5  4  3  4  5  6  7  8  9 10 
 9  8  7  6  5  4  3  2  3  4  5  6  7  8  9 
 8  7  6  5  4  3  2  1  2  3  4  5  6  7  8 
 7  6  5  4  3  2  1  0  1  2  3  4  5  6  7 
 8  7  6  5  4  3  2  1  2  3  4  5  6  7  8 
 9  8  7  6  5  4  3  2  3  4  5  6  7  8  9 
10  9  8  7  6  5  4  3  4  5  6  7  8  9 10 
11 10  9  8  7  6  5  4  5  6  7  8  9 10 11 
12 11 10  9  8  7  6  5  6  7  8  9 10 11 12 
13 12 11 10  9  8  7  6  7  8  9 10 11 12 13 
14 13 12 11 10  9  8  7  8  9 10 11 12 13 14 

In: Computer Science

Java Language: Using program created in this lesson as a starting point, create a circular list...

Java Language:

Using program created in this lesson as a starting point, create a circular list with at least four nodes. A circular list is one where the last node is made to point to the first. Show that your list has a circular structure by printing its content using an iterative structure such as a while. This should cause your program to go into an infinite loop so you should include a conditional that limits the number of nodes to be printed to a specific value, for example 20.

Code:

class Node {

int value;

Node nextNode;

Node(int v, Node n)

{

value = v;

nextNode = n;

}

Node (int v)

{

this(v,null);

}

}


class Stack {

protected Node top;

Stack()

{

top = null;

}

boolean isEmpty()

{

return( top == null);

}

void push(int v)

{

Node tempPointer;

tempPointer = new Node(v);

tempPointer.nextNode = top;

top = tempPointer;

}

int pop()

{

int tempValue;

tempValue = top.value;

top = top.nextNode;

return tempValue;

}

void printStack()

{

Node aPointer = top;

String tempString = "";

while (aPointer != null)

{

tempString = tempString + aPointer.value + "\n";

aPointer = aPointer.nextNode;



System.out.println(tempString);

}

}

public class StackWithLinkedList{

public static void main(String[] args){

int popValue;

Stack myStack = new Stack();

myStack.push(5);

myStack.push(7);

myStack.push(9);

myStack.printStack();

popValue = myStack.pop();

popValue = myStack.pop();

myStack.printStack();

}

}

In: Computer Science

The following activities are part of a project to be scheduled using CPM: Activity Immediate Pred...

The following activities are part of a project to be scheduled using CPM:

Activity

Immediate Pred

Weeks

A

-

6

B

A

3

C

A

7

D

B, C

2

E

C

4

F

D

3

G

E, F

7

  1. Please draw the network.
  2. What is the critical path?
  3. How many weeks will it take to complete the project?
  4. How much slack does each of the activities have?

Question A: Drawing the network

Questions B,C,D use an excel file

In: Operations Management

Marketers know that both the social elements of the service encounter (i.e., the employee and the...

Marketers know that both the social elements of the service encounter (i.e., the employee and the customer) and the physical elements, including the servicescape, are important to a positive service experience. To measure service quality, marketers use the SERVQUAL scale, which measures five (5) dimensions of service quality.

  1. List the five dimensions of service quality.
  2. Briefly explain each of the five dimensions of service quality.
  3. Gap analysis is a related metric. What is gap analysis – what does it measure, and why is understanding this important to marketers?

In: Operations Management

. Refer to the accompanying table showing results from a Chembio test for Hepatitis C among...

. Refer to the accompanying table showing results from a Chembio test for Hepatitis C among HIV-infected patients.

Positive Test Result

Negative Test Result

Hepatitis C

335

10

No Hepatitis C

2

1153

a. Find the probability of selecting a subject with a positive test result, given that the subject does not have hepatitis C. Why is this case problematic for test subjects?

b. Find the probability of selecting a subject with a negative test result, given that the subject has hepatitis C. What would be an unfavorable consequence of this error?

c. Find the positive predictive value for the test. That is, find the probability that a subject has hepatitis C, given that the test yields a positive result. Does the result make the test appear to be effective?

d. Find the negative predictive value for the test. That is, find the probability that a subject does not have hepatitis C, given that the test yields a negative result. Does the result make the test appear to be effective?

In: Math

Typing errors in a text are either nonword errors (as when "the" is typed as "teh")...

Typing errors in a text are either nonword errors (as when "the" is typed as "teh") or word errors that result in a real but incorrect word. Spell‑checking software will catch nonword errors but not word errors. Human proofreaders catch 70%70% of word errors.

You ask a fellow student to proofread an essay in which you have deliberately made 1010 word errors.

(a) If ?X is the number of word errors missed, what is the distribution of ?X ? Select an answer choice.

?X is approximately Normal with ?=3μ=3 and ?=1.45σ=1.45

?X is binomial with ?=10n=10 and ?=0.3p=0.3

?X is binomial with ?=10n=10 and ?=0.7p=0.7

?X is Normal with ?=7μ=7 and ?=1.45σ=1.45

If ?Y is the number of word errors caught, what is the distribution of ?Y ? Select an answer choice.

?Y is binomial with ?=10n=10 and ?=0.7p=0.7

?Y is binomial with ?=10n=10 and ?=0.3p=0.3

?Y is approximately Normal with ?=3μ=3 and ?=1.45σ=1.45

?Y is Normal with ?=7μ=7 and ?=1.45σ=1.45

(b) What is the mean number of errors caught? (Enter your answer as a whole number.)

mean of errors caught =

What is the mean number of errors missed? (Enter your answer as a whole number.)

mean of errors missed =

(c) What is the standard deviation of the number of errors caught? (Enter your answer rounded to four decimal places.)

standard deviation of the number of errors caught =

What is the standard deviation of the number of errors missed? (Enter your answer rounded to four decimal places.)

standard deviation of the number of errors missed =

In: Math

list one possible cause for each of the following cardiac abnormalities. abnormal t waves abnormal p-r...

list one possible cause for each of the following cardiac abnormalities.


abnormal t waves
abnormal p-r interval

In: Anatomy and Physiology

Preparation What started as a promotional strategy among several large U.S. retailers has grown into an...

Preparation

What started as a promotional strategy among several large U.S. retailers has grown into an annual, nationwide shopping event held the day after Thanksgiving: Black Friday. Every year, Black Friday sales get larger, the stores open earlier, the prices get lower, and, unfortunately, the even often includes angry crowds of shoppers, desperate to be the first ones to get a good deal. Black Friday has also given rise Cyber Monday, its online counterpart. There are even businesses that use an anti–Black Friday position as a marketing strategy! Black Friday has spread to Britain, and since 2015, citizens across the United Kingdom have also been able to share in the madness of this pseudo holiday.

For Discussion

From a marketing perspective, you need to make a decision about whether participating in Black Friday madness makes sense, given your target market and customers. Given this perspective, do you believe that ignoring Black Friday is a viable marketing decision? Why or why not? What segment of the market do Black Friday and Cyber Monday target? Discuss whether you believe that the targeted market segments are the same for all businesses. Finally, are you a Black Friday shopper? Why or why not?

In: Operations Management

A voltaic cell consists of an Mn/Mn2+ half-cell and a Pb/Pb2+ half-cell. Calculate [Pb2+] when [Mn2+]...

A voltaic cell consists of an Mn/Mn2+ half-cell and a Pb/Pb2+ half-cell. Calculate [Pb2+] when [Mn2+] is 2.7 M and Ecell = 0.35 V.

In: Chemistry

You have been asked to set-up remote meetings due to the spread COVID-19. Share which remote...

You have been asked to set-up remote meetings due to the spread COVID-19. Share which remote learning program you will utilize and explain why you selected the option. Your response must consist of a minimum of 15 complete sentences.

In: Operations Management

Describe the difference between making a class a member of another class (object composition) and making...

Describe the difference between making a class a member of another class (object composition) and making a class a friend of another class.


Explain why memberwise assignment can cause problems with a class that contains a pointer member.


Explain why the parameter of a copy constructor must be a reference.


In: Computer Science

Java- creat a method that takes two char parameters. Return a String containing all characters, in...

Java- creat a method that takes two char parameters. Return a String containing all characters, in order, from the first char parameter (inclusive) to the last (inclusive). For instance, input('a', 'e'), and return "abcde".

In: Computer Science

Arithmetic Expression Evaluation Write a program that reads an infix expression (that contains only A, B...

Arithmetic Expression Evaluation
Write a program that reads an infix expression (that contains only A, B and/or C as operands) from
the user and prints out the value of the expression as an output.
Implement the following methods:

o String infixToPostfix(String expr)
Converts the given infix expression expr and returns the corresponding postfix notation
of expr.
o Integer evaluatePostfixExpr(String expr)
Evaluates and returns the value of the given postfix expression expr.

Sample Input/Output #1
Enter your arithmetic expression: A+B-C*A
Enter the value of A: 5
Enter the value of B: 10
Enter the value of C: 2
The postfix expression is AB+CA*-
The above expression evaluates to 5.
Sample Input/Output #2
Enter your arithmetic expression: A+BC
Enter the value of A: 5
Enter the value of B: 10
Enter the value of C: 2
The above expression is invalid and can't be evaluated.


In: Computer Science

Generate 5th order linear recursive sequence using shift registers using the primitive polynomial 1+X^2+x^5

Generate 5th order linear recursive sequence using shift registers using the primitive polynomial 1+X^2+x^5

In: Computer Science

In Java An outlet store is having a sale in their Cabin brand sweaters. There are...

In Java

An outlet store is having a sale in their Cabin brand sweaters. There are two different pricing systems depending on if it is a Cabin brand or not. Tax must be added on after the sweater charge is computed.
You must have two classes using separate files.

Requirements for Sweater Class
Fields
1. sweater price (in dollars)
2. Boolean to indicate if it is a Cabin brand or not
3. number of sweaters purchased
Methods
1.   One 3 parameter constructor- the constructor uses three parameters representing the sweater price, whether it is a Cabin Brand or not, and the number of sweaters purchased.
2.   Getter and setter for each field
3.   getTotalPurchase method
This method must call the appropriate getter member methods where necessary. Do not access the fields directly.
This method calculates and returns the total amount of the sweater.
If the sweater is Cabin brand, calculate the discount as follows;
-If the customer purchases 1 sweater the discount is 20% of the sweaters price.
-if the customer purchases 2 or more sweaters the discount is 30%
-the customer cannot purchase less than 1 sweater.
-compute the purchase subtotal by subtracting the appropriate discount from the sweaters price.
Use a tax rate of 7% of the purchase subtotal to compute the sales tax in dollars. Add the sales tax amount to the purchase subtotal to determine the total purchase amount.
Return the total purchase amount to the calling code.

Requirements for the SweaterDriver Class
Main method
1.   customer must be prompted appropriately
2.   All values related to money may include values after the decimal point. All values displayed to the screen must display with 2 places after the decimal.
3.   The customer must indicate whether the sweater is Cabin brand or not by typing a single character (y for yes, n for no) program must accept Upper and lower case, Y,y,N,n.
4.   If the sweater is Cabin brand, prompt the customer to enter the number of Cabin sweaters being purchased.
5.   Instantiate a Sweater object using a three parameter constructor.
Note that the parameter that indicates if the sweater is a Cabin brand is a Boolean data type.
The customer must type a single character. You will have to use selection to instantiate a Sweater object with the correct data type foe this parameter.
6.   Display the values in the output by calling the appropriate method of the Sweater object. The output must line up at the decimal point as in the sample runs.
Sample runs
1
Enter the price of the sweater: $50.00
Is the swear a Cabin(Y/N)? N

Price of sweater $50.00
Total purchase $53.50

Run 2
Enter the price of the sweater: $60.00
Is the sweater a Cabin(Y/N)? Y
Enter the number of sweaters being purchased: 2
Price of sweater $60.00
Total Purchase $89.88

Run 3

Enter price of sweater: $40.00
Is the sweater a Cabin(Y/N)? Y
Enter the number of sweaters being purchased: 1
Price of sweater $40.00
Total purchase $34.24

In: Computer Science