Mean and standard deviation. Write a
However, this formula is not suitable for the task. By the time the program has computed
You can compute this quantity by keeping track of the count, the sum, and the sum of squares as you process the input values.
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Big Java Late Objects
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Objects (6th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Database Concepts (7th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Software Engineering (10th Edition)
- 1. Write a program to fill in a two-dimensional array of boolean values by setting a[i][j] to 1 if the greatest common divisor of i and j is 1. Else if the greatest common divisor is not 1, then set a[i][j] to 0. Sample Input: /a.out 6 Sample Output: 000000 011111 010101 011011 010101 011110arrow_forwardWrite a program that reads a 2D array of chars, checks, and corrects each char within this array, and print out the corrected 2D array. First the program will read the row count (rowCount) and column count (columnCount) of the 2D array, both as int values. Then, the chars constituting the 2D array will be read on a row-by-row basis. After reading the 2D array, the program will check and correct each char within the 2D array according to the rules below. This process MUST be done by using a void function by sending the appropriate cell of the 2D array with a call-by-reference fashion. If the row index is an even number, a char can only be a digit value. If the row index is an odd number, a char can only be an uppercase English letter. • Any incorrect value MUST be changed into Finally, the checked and corrected 2D array will be printed out to the screen. NOTE: Checking the correctness of a char and correcting it (if necessary) MUST be done in the function with a call-by-reference…arrow_forwardProblem 2: Postman Harry Harry is a postman. He's got a post office with a size of n rows and m columns. Each slot at the post office contains a number of letters. Harry can only go right and down. He starts at (0, 0), and ends at (n-1, m-1). Write a program that calculates the maximum amount of letters Harry can pick up. He can only pick up letters from a slot if he is on that slot. If the amount of letters is the same down and right, go right. Sample input/output: Enter the number of rows and columns: 35 Enter the number of letters in the 5 slots of row number 1: 5 2 60 1 Enter the number of letters in the 5 slots of row number 2: 2 4 3 9 2 Enter the number of letters in the 5 slots of row number 3: 8 72 3 4 The maximum number of letters Harry can pick is 32 solve using c++; (chapter 9: Variables / Assignments)arrow_forward
- Write a program that reads a list of integers from input into an array and outputs "yes" if the list is sorted in ascending order between two provided positions. Otherwise, output "no". The first input specifies the number of items in the list. The next set of inputs is the list. The last two inputs are the start and end positions (inclusive). Assume the list contains less than 20 integers and position 1 is the first element. Ex: If the input is: 8 5 6 7 4 3 2 1 0 1 3 the output is: yes Ex: If the input is: 6 1 2 3 4 5 2 4 6 the output is: noarrow_forwardUse C++arrow_forwardWrite a program that calculates the equivalent resistance of a circuit. n electrical resistors with resistance values R1, R2,.., Rn are said to be connected in parallel if the same voltage is applied across each. Their equivalent resistance Reg is related to the values R1, R2, ..., Rn by: 1 1 1 1 + +...+ R R R, R. "eq Write a program that prompts the user to enter the resistance of n resistors. The user should be prompted continuously by using a while loop until a zero or negative value is entered (the program should count the number of resistors n entered by the user and store the values in an array). Use another separate loop to print the resistance values entered by the user and the equivalent resistance Reg. Test your program with R1= 1 kn, R2= 2 kn, R3= 4 kQ and R4= 8 kQ.arrow_forward
- A run is a sequence of adjacent repeated values. Write a program that generates a sequence of 20 random die tosses in an array and that prints the die values, marking the runs by including them in parentheses, like this: 12 (5 5) 3 124 3 (2 22 2) 3 6 (5 5) 6 3 1 Use the following pseudocode: 1. Set a boolean variable inRun to false 2. For each valid index i in the array A. If inRun If values[i] is different from the preceding value Print ) o inRun = false · If not inRun o If values[i] is the same as the following value Print ( inRun = true. Print values[i] 3. If inRun, print )arrow_forwardExercise 2: In probability theory, one problem that often arises is determining the number of ways in which p objects can be selected from n distinct objects without regard to the order in which they are selected. Such selections are called combinations. The number of combinations ofp objects from a set with n objects is C (n, p) and is given by: n! C(n, p) = (п - р)! * р! Write a Python program which will calculate and display on the screen the number of possible combination C based on the values of n and p; where both n and p are positive integers less than 21 and n> p. Implement and use at least the following three functions: fact(..): A function when passed a positive integer value, will calculate and return the factorial of that number. comb(.): A function when passed n and p (n: total number of objects and p: number of objects taken at a time) will calculate and return the total number of possible combinations (using the formula above). It calls function fact(.) main(..): reads…arrow_forwardImplement a program that reads two integers (n and k). The program must output the binomial coefficient as follows: Print every coefficient that is before binomial coefficient for given k; Example: Insert n: 5 Insert k: 3 Result: 10 Coefficient-array: 1 5 10 10 Print Pascal Triangle for the given n: Example (n=5): 1 11 121 1331 14641 15 10 10 5 1arrow_forward
- Jems. Akka Downvote.arrow_forwardCode language Java 1, Add a print statement to say “Multiplication Table” and then prompt theuser to enter an integer. Your program should then prints “times table” for thenumbers from 1 to the given integer (inclusive). That is, for input n, you would printa table of n rows (lines) each with n columns, where the cell at row i and columnj contains the value i × j. You do need separate rows, but don’t worry about thecolumns lining up nicely yet. 2. Add a print statement to say “Prime Testing”.Using the integer entered by the user above, print out all the prime numbers between2 and the number squared. E.g., if the user types 12 for the multiplication table part,you should print all the prime numbers that are not larger than 144.All integers are either prime or composite. A prime number is one that has no integerfactors other than itself or one. Examples are 2, 3, 5, 7, 11, 13, . . .. A compositenumber, by contrast, has multiple factors. Examples are 4, 6, 12, 15, 18, 21, . . ..Testing…arrow_forwardFastarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr