Questions
please write it in printf and scanf please Please write it in c# program please and...

please write it in printf and scanf please Please write it in c# program please and if possible no arrays only loops Loop Introduction Assignment Using the conditions below, write one program that calculates a person’s BMI. Your main() function will call functions 1, 2, and 3. Your program will contain three functions: Function #1: Will ask the user for their weight in pounds and their height in inches. Your function will convert the weight and height into Body Mass Index (BMI). The formula for converting weight into BMI is as follows: BMI = Weight * 703 / Height2 Your function will do this using a for loop and must display the BMI for 3 people, one at a time. In other words, display the BMI for person 1 before asking for the next person’s information. Function #2: This function will do the exact same thing as function #1, except you will use a do-while loop. Function #3: Using a while loop, write the same steps as function #1, but as an indefinite loop where we continue to ask the user if they would like to calculate the BMI again. Continue to do so until the user replies with either an ‘N’ or an ‘n’ Reserve Point Opportunity!! Complete the above program calling a fourth function that will calculate and return the BMI.

In: Computer Science

Java Programming Using the class below, please ), write a static method called parse that parses...

Java Programming

Using the class below, please

  1. ), write a static method called parse that parses a String for balanced parentheses. we seek only to determine that the symbol ‘{‘ is balanced with ‘}’. parse accepts a single String parameter and returns an int. If parse returns a minus 1, then there are no errors, otherwise, parse should return the position within the String where an error occurred. For example

parse(“{3 + {4/2} }”)   would return -1

parse(“{ { 4*X}”) would return 6 since at position 6 we expected another “}”

parse(“{3+4}}”) would also return a 6

In: Computer Science

(a) Explain the difference between big-O and big-theta, and give examples of each to show the...

(a) Explain the difference between big-O and big-theta, and give examples of each to show the difference.
(b) How can we say that two functions have the same asymptotic complexity, using big-theta notation?
(c) Rank the following functions in order of increasing complexity (rate of growth), and indicate which functions have the same asymptotic complexity.
x2; x log(x); 2x; log(x) + 7; 92x2 + 57x + 3921; 4x; 27x2 + 8x3; 22x+5; log(x42); 3x + 12.

In: Computer Science

Have you ever had to deal with a virus? What steps did you take to get...

Have you ever had to deal with a virus? What steps did you take to get rid of the virus? Could you have avoided infection in the first place? What did you learn from the experience?

In: Computer Science

(1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds....

(1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output the list. (2 pts)

Ex:

Enter weight 1: 236
Enter weight 2: 89.5
Enter weight 3: 176.0
Enter weight 4: 166.3

Weights: [236.0, 89.5, 176.0, 166.3]

(2) Output the average of the list's elements. (1 pt)

(3) Output the max list element. (1 pt)

Ex:

Enter weight 1: 236
Enter weight 2: 89.5
Enter weight 3: 176.0
Enter weight 4: 166.3

Weights: [236.0, 89.5, 176.0, 166.3]
Average weight: 166.95
Max weight: 236.0

(4) Prompt the user for a number between 1 and 4. Output the weight at the user specified location and the corresponding value in kilograms. 1 kilogram is equal to 2.2 pounds. (3 pts)

Ex:

Enter a list index (1 - 4): 3
Weight in pounds: 176.0
Weight in kilograms: 80.0

(5) Sort the list's elements from least heavy to heaviest weight. (2 pts)

Ex:

Sorted list: [89.5, 166.3, 176.0, 236.0]

This is what I have so far:

# FIXME (1): Prompt for four weights. Add all weights to a list. Output list.
weights = []
for i in range(4):
w = float(input("Enter weight "+str(i+1)+":"))
weights.append(w)
print("\nWeights:",weights)

# FIXME (2): Output average of weights.
avg = sum(weights) / float(len(weights))
print("Average weight:",avg)

# FIXME (3): Output max weight from list.
print("Max weight:",max(weights))

# FIXME (4): Prompt the user for a list index and output that weight in pounds and kilograms.
index = int(input("\nEnter a list index location (1 - 4): \n"))
print("Weight in pounds:",weights[index-1])
print("Weight in Kilograms:",weights[index-1]/2.2)

# FIXME (5): Sort the list and output it.
weights.sort()
print("\nSorted list:",weights)

Your output starts with

Enter weight 1:

Weights: [236.0]

Enter weight 2:

Weights: [236.0, 89.5].

Enter weight 3:

Weights: [236.0, 89.5, 176.0]

Enter weigt 4:

Weights: [236.0, 89.5, 176.0, 166.3]

Expected output starts with

Enter weight 1:

Enter weight 2:

Enter weight 3:

Enter weight 4:

Weights: [236.0, 89.5, 176.0, 166.3]

How do I fix this!?

In: Computer Science

Has copyright been extended too long? How is it being abused? Does it still serve its...

Has copyright been extended too long? How is it being abused? Does it still serve its original purpose (promoting progress), or has it become a tool to prevent 'unauthorized' voices from being heard? Should software be patentable? Has the trend toward privatization and branding everything in sight gone too far? If so...what might be done? Intellectual Property is all about tradeoffs and competing interests--where should the balance be?

In: Computer Science

Q. Explain how to invoke a superclass method from a subclass method for the case in...

Q. Explain how to invoke a superclass method from a subclass method for the case in which the subclass method overrides a superclass method and the case in which the subclass method does not override a superclass method. [1 Mark]

this is a correct answer but i want answer it  in different way   :

  • In the case where the subclass method overrides the superclass method, it is necessary to explicitly use the keyword super, to invoke the method of the superclass as super.methodName().

    When the subclass method does not override the superclass method, the superclass method can be invoked simply by using its name and appropriate arguments.

In: Computer Science

Write a JAVA program by making a LOGIN form using Excel file for validation. if user...

Write a JAVA program by making a LOGIN form using Excel file for validation. if user is found, display the user's First Name and Last Name.


In: Computer Science

Programming Assignment #2, Processes Write a C program (time_shm.c) that determines the amount of time necessary...

Programming Assignment #2, Processes

  1. Write a C program (time_shm.c) that determines the amount of time necessary to run a command from the command line. This program will be run as

./time <command [args...]>

and will report the amount of elapsed time to run the specified command. This will involve using fork() and execvp() functions, as well as the gettimeofday() function to determine the elapsed time. It will also require the use of two different IPC mechanisms.

The general strategy is to fork a child process that will execute the specified command. However, before the child executes the command, it will record a timestamp of the current time (which we term “starting time”). The parent process will wait for the child process to terminate. Once the child terminates, the parent will record the current timestamp for the ending time. The difference between the starting and ending times represents the elapsed time to execute the command. The example output below reports the amount of time to run the command ls:

./time ls -l

total 156

25616 Feb

4

15:59 a.out

-rwxr-xr-x 1 thomas users

-rw-r--r-- 1 thomas users

252 Feb

4

16:00 output.txt

-rwxr-xr-x 1

thomas users

86024

Feb

2

20:58 project.exe

-rwxr-xr-x 1

thomas users

25616

Feb

2

21:00 time

-rw-r--r-- 1

thomas users

5144

Feb

2

20:58 time.c

Elapsed time: 0.001448 seconds

As the parent and child are separate processes, they will need to arrange how the starting time will be shared between them. You will write one version of this program, representing a method of IPC.

2a) The first version, time_shm.c, will have the child process write the starting time to a region of shared memory before it calls execvp(). After the child process terminates, the parent will read the starting time from shared memory. The region of shared memory should be established before the child process is forked, allowing both the parent and child processes access to the region of shared memory.

You will use the gettimeofday() function to record the current timestamp. This function is passed a pointer to a struct timeval object, which contains two members: tv_sec and tv_usec. These represent the number of elapsed seconds and microseconds since January 1, 1970 (known as the UNIX EPOCH). The following code sample illustrates how this function can be used:

  • Get current time timeval_t startTime; gettimeofday( &startTime, 0 );
  • get the end time

timeval_t end_time;

gettimeofday( &end_time, 0 );

  • calculate elapsed time timeval_t elapsed_time;

timersub( &end_time, startTime, &elapsed_time );

// print elapsed time (microseconds right justified zero filled)

printf( "\nElapsed time: %d.%06d seconds\n", elapsed_time.tv_sec, elapsed_time.tv_usec );

Hint:

  1. For IPC between the child and parent processes, the contents of the shared memory pointer can be assigned the struct timeval representing the starting time. When pipes are used, a pointer to a struct timeval can be written to - and read from - the pipe.
  1. gcc time_shm.c -otime -lrt is an example command to compile and link your program

3.    ./time ls -l | tee time_shm_output.txt is an example command to run your program while collecting your program’s output to a text file and seeing the output on the console.

In: Computer Science

A password verification system that does not allow user passwords to be proper names or words...

A password verification system that does not allow user passwords to be proper names or words that are normally included in a dictionary is an example of ___________ with respect to security systems.

Group of answer choices

Attack

Risk

Asset

Countermeasure

In: Computer Science

Describe a hypothetical scenario where someone would act in ways that are not legal, but it...

Describe a hypothetical scenario where someone would act in ways that are not legal, but it is ethical. Describe a hypothetical scenario where someone would act in ways that are legal, but not ethical

In: Computer Science

Q1# Consider the following string: String hello = "Hi girls! hope your assignment1 is very easy.";...

Q1# Consider the following string:
String hello = "Hi girls! hope your assignment1 is very easy.";
a. What is the value displayed by the expression hello.length()?
b. What is the value returned by the method call hello.charAt(12)?
c. Write an expression that refers to the letter p in the string referred to by hello


Q2# Modify the program to use a "while-do" loop instead of "for" loop.


int sum = 0;
int number = lowerbound; // declare and init loop index variable
while (number <= upperbound) { // test
sum += number;
++number; // update
}

In: Computer Science

Bucket sort is an algorithm that falls into the category of "specialized" sorts that have certain...

Bucket sort is an algorithm that falls into the category of "specialized" sorts that have certain advantages but rely on properties of the array that may not be suitable for all situations. The algorithm itself is simple and uses an array of counters. Given an array of size n, the pseudocode is:

Initialize an array of integers of size range(n), bucketCount[], all set to 0

For i in each array element 0 ... n

increase bucketCount[array[i]] by 1

range(n) is the numeric range of the input (for example: if the numbers fall into the range 0-49, you would need an array of 50 counters).

After completing the above loop, you can use another loop to rearrange values into sorted order using the counters in bucketCount[].

Assignment

  1. Add an implementation of bucketSort() to your template from Lab 5. You can leave the existing sort() function in the code (and use a new name for this one) or replace the existing sort() function.
  2. Verify that the array is sorted in ascending order using the same way as before (verifying a[i + 1] >= a[i] for all i).
  3. You can assume that your input falls into a certain range (i.e. restrict them during the add() operation). This would also determine the size of your counters array.
  4. After verifying that your code is correct, consider these questions,
    • What do you think is the "big O" complexity of this algorithm?
    • What is the main limitation of this method of sorting? Why doesn't it work for everything?
    • Leave your answers in the comments along with your code.

In: Computer Science

In the space provided below write a C program that computes the total cost of items...

In the space provided below write a C program that computes the total cost of items you want to order online. It does so by first asking how many items are in your shopping cart and then based on that number, it repeatedly asks you to enter the cost of each item. It then adds a 5% delivery charge for standard delivery if the total is below $1,000, and an additional 10% charge if you want an expedited next day delivery.

In: Computer Science

Question 2. Explain preprocessor directives in C++. Describe Error and pragma directives and write code snippets....

Question 2.

Explain preprocessor directives in C++.

  1. Describe Error and pragma directives and write code snippets.
  2. Describe define, and undef, directives.
  3. Write the code which shows if constant “VALUE” is not defined then define it and replace its value to 5 on runtime. Display the value of x.

int x = VALUE;

In: Computer Science