The mathematical constant Pi is an irrational number with value approximately 3.1415928... The precise value of this constant can be obtained from the following infinite sum:
Pi^2 = 8+8/3^2+8/5^2+8/7^2+8/9^2+...
(Pi is of course just the square root of this value.)
Although we cannot compute the entire infinite series, we get a good approximation of the value of Pi' by computing the beginning of such a sum. Write a function approxPIsquared that takes as input float error and approximates constant Pi to within error by computing the above sum, term by term, until the difference between the new and the previous sum is less than error. The function should return the new sum
>>>approxPIsquared(0.0001)
9.855519952254232
>>>approxPIsquared(0.00000001)
9.869462988376474

Answers

Answer 1

Answer:

I am writing a Python program:

def approxPIsquared(error):

   previous = 8

   new_sum =0

   num = 3

   while (True):

       new_sum = (previous + (8 / (num ** 2)))

       if (new_sum - previous <= error):

           return new_sum

       previous = new_sum

       num+=2    

print(approxPIsquared(0.0001))

Explanation:

I will explain the above function line by line.

def approxPIsquared(error):  

This is the function definition of approxPlsSquared() method that takes error as its parameter and approximates constant Pi to within error.

previous = 8     new_sum =0      num = 3

These are variables. According to this formula:

Pi^2 = 8+8/3^2+8/5^2+8/7^2+8/9^2+...

Value of previous is set to 8 as the first value in the above formula is 8. previous holds the value of the previous sum when the sum is taken term by term. Value of new_sum is initialized to 0 because this variable holds the new value of the sum term by term. num is set to 3 to set the number in the denominator. If you see the 2nd term in above formula 8/3^2, here num = 3. At every iteration this value is incremented by 2 to add 2 to the denominator number just as the above formula has 5, 7 and 9 in denominator.

while (True):  This while loop keeps repeating itself and calculates the sum of the series term by term, until the difference between the value of new_sum and the previous is less than error. (error value is specified as input).

new_sum = (previous + (8 / (num ** 2)))  This statement represents the above given formula. The result of the sum is stored in new_sum at every iteration. Here ** represents num to the power 2 or you can say square of value of num.

if (new_sum - previous <= error):  This if condition checks if the difference between the new and previous sum is less than error. If this condition evaluates to true then the value of new_sum is returned. Otherwise continue computing the, sum term by term.

return new_sum  returns the value of new_sum when above IF condition evaluates to true

previous = new_sum  This statement sets the computed value of new_sum to the previous.

For example if the value of error is 0.0001 and  previous= 8 and new_sum contains the sum of a new term i.e. the sum of 8+8/3^2 = 8.88888... Then IF condition checks if the

new_sum-previous <= error

8.888888 - 8 = 0.8888888

This statement does not evaluate to true because 0.8888888... is not less than or equal to 0.0001

So return new_sum statement will not execute.

previous = new_sum statement executes and now value of precious becomes 8.888888...

Next   num+=2  statement executes which adds 2 to the value of num. The value of num was 3 and now it becomes 3+2 = 5.

After this while loop execute again computing the sum of next term using       new_sum = (previous + (8 / (num ** 2)))  

new_sum = 8.888888.. + (8/(5**2)))

This process goes on until the difference between the new_sum and the previous is less than error.

screenshot of the program and its output is attached.

The Mathematical Constant Pi Is An Irrational Number With Value Approximately 3.1415928... The Precise

Related Questions

Search the web to discover the 10 most common user-selected passwords, and store them in an array. Design a program that prompts a user for a password, and continues to prompt the user until the user has not chosen one of the common passwords. Ensure that you store their password and can add that to the list so they cannot choose that password when they must change their password in the future.

Answers

Answer:

passwords = ["123456", "123456789", "qwerty", "password", "111111", "12345678", "abc123", "1234567", "password1", "12345"]

used_passwords = []

while True:

   password = input("Choose a password: ")

   

   if password in passwords:

       print("You must not choose a common password!")

       continue

   elif password in used_passwords:

       print("You used this password before. Choose a new one.")

       continue

   else:

       used_passwords.append(password)

       break

Explanation:

*The code is in Python.

Initialize the passwords array with 10 most common user-selected passwords

Initialize the used_passwords array as empty

Create an infinite while loop. Inside the loop, ask the user to choose a password. Check if entered password is in the passwords or not. If it is, print a warning and ask the user to choose again using continue statement. If the entered password is in the used_passwords, print a warning message and ask the user to choose again using continue statement. If the previous conditions are not satisfied, it means the password is valid. Add the password to the used_passwords array and stop the loop using break statement.


Conditioning the temperature a computer lab to extend the life of the computers and
improve their performance is known as heating and cooling.
industrial
modern
environmental
process​

Answers

Answer:

environmental

Explanation:

How do i make an Array in C++ Also how do i make it so i can Multithread on Java

Answers

Answer:

To start a thread we simply need to create a new thread object and pass the executing code to be called (i.e, a callable object) into the constructor of the object. Once the object is created a new thread is launched which will execute the code specified in callable. After defining callable, pass it to the constructor.

Explanation:

A service provider recently upgraded one of the storage clusters that houses non-confidential data for clients. The storage provider wants the hard drives back in working condition. Which of the following is the BEST method for sanitizing the data given the circumstances?

a. Hashing
b. Wiping
c. Purging
d. Degaussing

Answers

Answer:

c. Purging

Explanation:

Based on the information provided it can be said that the best method for sanitizing the data would be Purging. This is a process that permanently erases the data from a specific storage unit. Doing so prevents data from being recovered by an expert and also frees up storage and memory space to be used for other information. Since it is very inexpensive and provides the best overall results this would be the best option in this scenario.

Write a JavaScript to multiple 2 square matrices (3,3). You can use any numbers as elements of the matrix.

Answers

Answer:

Here is the JavaScript program:

function MatricesMul(matrix1, matrix2) {

   var product = [];

   for (var i = 0; i < matrix1.length; i++) {

       product[i] = [];

       for (var j = 0; j < matrix2[0].length; j++) {

           var total = 0;

           for (var k = 0; k < matrix1[0].length; k++) {

               total += matrix1[i][k] * matrix2[k][j];  }

           product[i][j] = total;        }    }

   return product;}

var matrix1 = [[1,2,3],[4,5,6],[7,8,9]]

var matrix2 = [[3,2,1],[6,5,4],[1,2,3]]

var output = MatricesMul(matrix1, matrix2)

document.write(output);

Explanation:

The function MatricesMul(matrix1, matrix2) takes two matrices (matrix1 and matrix2) as parameters.

var product = [];  product works as an array to contain the result of the multiplication of the two matrices matrix1 and matrix2.

for (var i = 0; i < matrix1.length; i++) this is a loop which iterates through the matrix1 and it continues to execute until the loop variable i exceeds the length of the matrix1. This is basically the loop which iterates through the rows of matrix1.

for (var j = 0; j < matrix2[0].length; j++) this is a loop which iterates through matrix2 and it continues to execute untill the loop variable j exceeds the length of the element of matrix2 at 0-th index (first element). This is basically the loop which iterates through the colulmns of matrix2.

var total = 0;  variable total is initialized to 0 and this variable is used to compute the sum.

for (var k = 0; k < matrix1[0].length; k++) this loop is used for the multiplication of the two matrices matrix1 and matrix2.

total += matrix1[i][k] * matrix2[k][j];  this statement first multiplies each element of matrix1 row to each element of the matrix2 column, takes the sum of pairwise products.

return product; returns the result of the multiplication of matrix1 and matrix2.

For example let matrix1 = [[1,2,3],[4,5,6],[7,8,9]]  and matrix2 = [[3,2,1],[6,5,4],[1,2,3]] .

The first for loop moves through each row of matrix1. The first element of first row of matrix1 is 1, the second element is 2 and third is 3. The second loop iterates through each column of matrix2. Lets take the first column matrix2. The first element of first column of matrix2 i.e. 3, the second element is 6 and the third is 1. Third loop performs the pairwise multiplication of row of matrix1 to column of matrix2 and takes the sum of pairwise product. This means 1 is multiplied to 3, 2 is multiplied with 6 and 3 is multiplied to 1. This will take the form: 1*3 + 2*6 + 3*1 = 3 + 12 + 3 Now their sum is taken and the result is stored in total variable. So the sum of 3 + 12 + 3 is 18. This process will continue until all the rows elements of matrix1 and elements in all columns of matrix2 are multiplied and the sum of each pairwise product is taken.

var matrix1 = [[1,2,3],[4,5,6],[7,8,9]]

var matrix2 = [[3,2,1],[6,5,4],[1,2,3]]

The above two statements two (3,3) square matrices are given values.

var output = MatricesMul() this calls the MatricesMul method and passes the two matrices (matrix1, matrix2) to the function and stores the result of this multiplication to output variable.

document.write(output); displays the result of the multiplication of two square matrices .

.Pretend you are ready to buy a new computer for personal use.First, take a look at ads from various magazines and newspapers and list terms you don’t quite understand. Look up these terms and give a brief written explanation. Decide what factors are important in your decision as to which computer to buy and list them. After you select the system you would like to buy, identify which terms refer to hardware and which refer to software.

Answers

Answer:

Brainly is not meant to give paragraph answers to large questions.

In a computer (desktop)

There are 8-9 main components to a PC

Motherboard

CPU

GPU (for gamers)

RAM

SSD

HDD

PSU

Cooling fans (for AMD processors stock fans are included)

Case (some fans included)

I personally build my computers (desktops) as its cheaper and I won't have to pay a build fee.

Automated implementation of an application's build, test, and deployment process is called as _____________________.

Answers

Answer:

Deployment pipeline.

Explanation:

Automated implementation of an application's build, test, and deployment process is called as deployment pipeline.

Generally, the main components of the deployment pipeline are the; build automation, test automation and deployment automation.

The main purpose why software engineers use the deployment pipeline is to enable them avoid any waste in the software development process, and to avail them the opportunity to give a rapid feedback to the production team during deployment of the software application. This ultimately implies that it involves the process of picking up a code from version control and presenting it to the end users of the software application in an automated manner.

Since, it is done automatically it helps to mitigate human errors and to meet customer's requirements.

What functions do these WLAN applications and tools perform on WLANs: airmonng, airodump-ng, aircrack-ng, and aireplay-ng

Answers

Answer:

The airmonng device allows for control mode on wireless LAN interfaces. Toggle between monitor mode and managed mode may also be used.

Explanation:

Without parameters entering the airmonng instruction will indicate the status of the operating system on the WLAN. Its  airodump-ng tool is used to capture packets of raw 802.11 blocks and is especially useful for processing vectors for WEP initial condition with both the motive that uses the others to aireplay-ng For injecting frames the aireplay-ng tool is used. The primary purpose of this injection is to create traffic which will later be used by the aircrack-ng to break the WEP and WPA-PSK keys.

For selection purposes, it is critical that application items have a proven relationship between a selection device and some relevant criterion. This is called

Answers

Answer:

Validity

Explanation:

Personnel Selection encompasses all the processes and methods involved in the selection of workers. The purpose of personnel selection is to determine the best candidate for the job and in so doing the recruiting organization must play by the rules laid down by the government for recruitment. Validity refers to the relationship between interviews and excellent performance at the job.

Validity implies that the method of selection must meet up to a standard criterion. This standard criterion is the expected job performance required of the potential employee. Different interview types (such as job-related, situational, and psychological) have different validity levels.  

Convert the following numbers from decimal to binary, assuming unsigned binary representation:________.
A) 35
B) 3
C) 27
D) 16

Answers

Answer:

Binary representations of following are:

A) 35 = 100011

B) 3 = 11

C) 27 = 11011

D) 16 = 10000

Explanation:

The method to generate the binary number from a decimal is :

Keep on dividing the number by 2 and keep on tracking the remainder

And the quotient is again divided and remainder is tracked so that the number is completely divided.

And then write the binary digits from bottom to top.

Please have a look at the method in below examples:

A) 35

[tex]\begin{center}\begin{tabular}{ c c c }Number & Quotient & Remainder\\ 2 & 35 & 1 \\ 2 & 17 & 1 \\ 2 & 8 & 0 \\ 2 & 4 & 0 \\ 2 & 2 & 0 \\ 2 & 1 & 1\end{tabular}\end{center}[/tex]

Writing the remainder from bottom to top.

So, binary number is 100011

B) 3

[tex]\begin{center}\begin{tabular}{ c c c }Number & Quotient & Remainder\\ 2 & 3 & 1 \\ 2 & 1 & 1 \\ \end{tabular}\end{center}[/tex]

Writing the remainder from bottom to top.

So, binary equivalent is 11.

C) 27

[tex]\begin{center}\begin{tabular}{ c c c }Number & Quotient & Remainder\\ 2 & 27 & 1 \\ 2 & 13 & 1 \\ 2 & 6 & 0 \\ 2 & 3 & 1 \\ 2 & 1 & 1 \end{tabular}\end{center}[/tex]

Writing the remainder from bottom to top.

So, binary equivalent is 11011.

D) 16

[tex]\begin{center}\begin{tabular}{ c c c }Number & Quotient & Remainder\\ 2 & 16 & 0 \\ 2 & 8 & 0 \\ 2 & 4 & 0 \\ 2 & 2 & 0 \\ 2 & 1 & 1 \\\end{tabular}\end{center}[/tex]

Writing the remainder from bottom to top.

So, binary equivalent is 10000.

Answers are:

Binary representations of following are:

A) 35 = 100011

B) 3 = 11

C) 27 = 11011

D) 16 = 10000

Let's revisit our lucky_number function. We want to change it, so that instead of printing the message, it returns the message. This way, the calling line can print the message, or do something else with it if needed. Fill in the blanks to complete the code to make it work.

def lucky_number(name):
number = len(name) * 9
___ = "Hello " + name + ". Your lucky number is " + str(number)
___

print(lucky_number("Kay"))
print(lucky_number("Cameron"))

Answers

Answer:

Replace the first blank with:

message = "Hello " + name + ". Your lucky number is " + str(number)

Replace the second blank with:

return message

Explanation:

The first blank needs to be filled with a variable; we can make use of any variable name as long as it follows the variable naming convention.

Having said that, I decided to make use of variable name "message", without the quotes

The next blank is meant to return the variable on the previous line;

Since the variable that was used is message, the next blank will be "return message", without the quotes

In other to make the function lucky_number return the message rather than print, we use the return keyword.

def lucky_number(name):

number = len(name) * 9

message = "Hello " + name + ". Your lucky number is " + str(number)

return message

In other to return a variable or expression in a defined function such as the lucky_number function defined above, all we have to do is use the return keyword with the message.

When we use :

print(message) : the output when the lucky_number function is called is that, content of the message variable is printed or displayed. However, return message would return message back to the caller making it useful in other parts of our program.

The returned value could also be printed using the statement :

print(lucky_number(name)) : This statement prints the content of the returned message variable.

Learn more : https://brainly.com/question/17027551

Your boss wants you to start making your own Ethernet cables to save the company money. What type of connectors will you need to order to make them?

Answers

Answer:

Bulk Ethernet Cable - Category 5e or CAT5e

Bulk RJ45 Crimpable Connectors for CAT-5e

Explanation:

What is the name of the provision of services based around hardware virtualization?

Answers

Explanation:

Hardware virtualization refers to the creation of virtual (as opposed to concrete) versions of computers and operating systems. ... Hardware virtualization has many advantages because controlling virtual machines is much easier than controlling a physical server.

The name of the provision of services based around hardware visualization is called cloud computing

The cloud hypervisor is the software that is made use of during hardware visualization. The hypervisor does the function of managing hardware resources involving the customer and the service provider.

The work of hypervisor is that it manages the physical hardware resource which is shared between the customer and the provider.

Read more on https://brainly.com/question/13088836?referrer=searchResults

Do transformers have life insurance or car insurance? If you chose life insurance, are they even alive?

Answers

Answer:

Car insurance

Explanation:

they are machines with ai

CHALLENGE ACTIVITY |
6.2.2: Function call in expression.
Assign to maxSum the max of (numa, numB) PLUS the max of (numy, numz). Use just one statement. Hint: Call FindMax() twice in an expression.
1. #include
2. using namespace std; passed
3.
4. double FindMax(double numi,
5. double num2) { double maxVal; emos
6.
7. // Note: if-else statements need not be understood to complete this activity
8. if (numi > num2) { // if num1 is greater than num2,
9. maxVal = num1; // then num1 is the maxVal.
10.
11. All tests passed else
12. {maxVal = num2; // Otherwise, // num2 is the maxval.
13.
14.
15. return maxVal;
16. }
17.
18. int main() {
19. double numA;
20. double numB;
21. double numY;
22. double numz;

Answers

Answer:

maxSum = FindMax(numA, numB) + FindMax(numY, numZ);  

The maxSum is a double type variable which is assigned the maximum of the two variables numA numB PLUS the maximum of the two variables numY numZ using FindMax function. The FindMax() method is called twice in this statement one time to find the maximum of numA and numB and one time to find the maximum of numY numZ. When the FindMax() method is called by passing numA and numB as parameters to this method, then method finds if the value of numA is greater than that of numB or vice versa. When the FindMax() method is called by passing numY and numZ as parameters to this method, then method finds if the value of numY is greater than that of numZ or vice versa. The PLUS sign between the two method calls means that the resultant values returned by the FindMax() for both the calls are added and the result of addition is assigned to maxSum.

Explanation:

This is where the statement will fit in the program.

#include <iostream>

using namespace std;

double FindMax(double num1, double num2) {

  double maxVal = 0.0;    

  if (num1 > num2) { // if num1 is greater than num2,

     maxVal = num1;  // then num1 is the maxVal.    }

  else {          

     maxVal = num2;  // num2 is the maxVal.   }

  return maxVal; }  

int main() {

  double numA;

  double numB;

  double numY;

  double numZ;

  double maxSum = 0.0;  

maxSum = FindMax(numA, numB) + FindMax(numY, numZ);  

  cout << "maxSum is: " << maxSum << endl;   }

Lets take an example to explain this. Lets assign values to the variables.

numA = 6.0

numB = 3.0

numY = 4.0

numZ = 9.0

maxSum =0.0

maxSum = FindMax(numA, numB) + FindMax(numY, numZ);  

FindMax(numA,numB) method call checks if numA>numB or numB>numA and returns the maximum of the two. Here numA>numB because 6.0 is greater than 3.0. So the method returns numA i.e. 6.0

FindMax(numY, numZ) method call checks if numY>numZ or numZ>numY and returns the maximum of the two. Here numZ>numY because 9.0 is greater than 4.0. So the method returns numZ i.e. 9.0

FindMax(numA, numB) + FindMax(numY, numZ) this adds the two values returned by the method FindMax for each call.

FindMax returned maxVal from numA and numB values which is numA i.e. 6.0.

FindMax returned maxVal from numY and numZ values which is numZ i.e. 9.0.

Adding these two values 9.0 + 6.0 = 15

So the complete statement  FindMax(numA, numB) + FindMax(numY, numZ) gives 15.0  as a result.

This result is assigned to maxSum. Hence

maxSum = 15

To see the output on the screen you can use the print statement as:

cout<<maxSum;

This will display 15

The code for function calling is coded below.

To assign the maximum sum of `(numA, numB)` plus the maximum of `(numY, numZ)` to the variable `maxSum` using just one statement, you can call the `FindMax()` function twice in an expression.

Here's the code:

maxSum = FindMax(numA, numB) + FindMax(numY, numZ);

This code calls the `FindMax()` function twice, once with the parameters `(numA, numB)` and again with the parameters `(numY, numZ)`.

It calculates the maximum of each pair of numbers using the `FindMax()` function and then adds the two maximum values together. The result is assigned to the `maxSum` variable.

Learn more about Function call here:

https://brainly.com/question/31798439

#SPJ6

A core authentication server is exposed to the internet and is connected to sensitive services. How can you restrict connections to secure the server from getting compromised by a hacker? Check all that apply.

Answers

Answer:

Secure firewall , Access Control Lists (ACLs) , and Bastion hosts

Explanation:

In this scenario, the best options to be able to accomplish this would be a Secure firewall , Access Control Lists (ACLs) , and Bastion hosts. A secure firewall and an access control list will prevent specific harmful files and computers from entering a network unless it has the proper clearance. A bastion host on the other hand is a special-purpose computer on a network specifically designed and configured to withstand attacks, acting as a secondary defense mechanism.

It is possible to restrict connections by using a secure firewall, bastion hosts, and access control lists (ACLs).

A firewall can be defined as a security device that protects the network by filtering traffic and blocking unauthorized access.

A bastion host is a computer in a network that is designed and configured to withstand attacks.

An access control list (ACL) refers to a table that indicates an operating system the access rights of each specific user.

In conclusion, it is possible to restrict connections by using a secure firewall, bastion hosts, and access control lists (ACLs).

Learn more in:

https://brainly.com/question/11921446

Explain why an organization's firewall should block incoming packets the destination address of which is the organization's broadcast address?

Answers

Answer:

The classification including its given topic has always been outlined in section through below justifications.

Explanation:

Whenever an application running seems to have the destination as either the destination network of the organization, it must use the sophisticated instruments. This would also pressure each host mostly on infrastructure to collect the traffic coming as well as processing the message. Increases system should perhaps be restricted because it will not significantly impact channel or device productivity.Therefore, the firewall of a standard operating organization will block certain traffic with IP addresses as destination host of the organization.Another thing to remember here seems to be that transmitted destination details are usually indicators of an intruder using only a target computer as something of a transmitter. An assailant utilizing a broadcasting channel can trigger the transmitter to occur on a different machine.  

Would these statements cause an error? Why or why not? int year = 2019; int yearNext = 2020; int & ref = year; & ref = yearNext;

Answers

Answer: YES

Explanation:

int year=2019;

int yearNext=2020;

 int &ref=year;

&ref=yearNext; {This line leads to error as references cannot be reassigned}

(//compilation error: lvalue required as left operand of assignment

) lvalue(&ref) is not something which can be assigned.

To get this better, here are the difference between pointers and reference variables

Pointers

Pointers can be incremented

Array can be formed with pointers

Pointers can be reassigned

Pointer can be declared as void  

Reference variable

References cannot be incremented

Array cannot be formed with references

References cannot be reassigned as references shares the address of the variable its assigned

References can never be void

What will be the tokens in the following statement? StringTokenizer strToken = new StringTokenizer("January 1, 2008", ", ", true);

Answers

Answer:

The tokens are:

January

space

1

,

space

2008

Explanation:

StringTokenizer class is basically used to break a string into tokens. The string consists of numbers, letters, quotation marks commas etc,

For example if the string is "My name is ABC" then StringTokenizer will break this string to following tokens:

My

name

is

ABC

So in the above example, the string is "January 1, 2008". It contains January with a space, then 1, then a comma, then 2008

The last comma and true in the statement do not belong to the string. They are the parameters of the StringTokenizer constructor i.e.

StringTokenizer(String str, String delim, boolean flag)

So according to the above constructor str= "January 1, 2008"

String delim is ,

boolean flag = true

So  the StringTokenizer strToken = new StringTokenizer("January 1, 2008", ", ", true); statement has:

a string January 1, 2008

a delim comma with a space (, ) which is used to tokenize  the string "January 1, 2008".

boolean flag set to true which means the delim i.e. (, ) is also considered to be a token in the string. This means the comma and space are considered to be tokens in the given string January 1, 2008.

Hence the output is January space 1 comma space 2008.

Check the attached image to see the output of the following statement.

A customer contacts the help disk stating a laptop does not remain charged for more than 30 minutes and will not charge more than 15%. Which of the following components are the MOST likely causes the issue? (Select three.) A. LCD power inverter B. AC adapter C. Battery D. Processor E. VGA card F. Motherboard G. Backlit keyboard H. Wireless antenna

Answers

Answer:

A. LCD power inverter

B. AC adapter

C. Battery

SUWIDHA stands for .​

Answers

SUWIDHA stands for Single User-friendly Window Disposal & Help-line for Applicants.

Hope it helps

A process can be A. single threaded B. multithreaded C. both single threaded and multithreaded D. none of the mentioned

Answers

Answer: C. both single threaded and multithreaded

Explanation:

A process can either be single threaded and multithreated. Single threaded processes is when the execution of instructions are in a single sequence i.e the sequence is one command at a time while for multithreaded processes, there are. execution of several multiple parts of a program that occurs at the same time.

A single threaded process only runs on one CPU, whereas for the execution of a multi-threaded, it may be divided amongst the available processors.

Write a program that reads in worked_example_1/babynames.txt and produces two files, boynames.txt and girlnames.txt, separating the data for the boys and girls.

Answers

Answer:

I am writing a JAVA program.

import java.util.Scanner;  //class to take input from user

import java.io.File;  //class for working with files

import java.io.FileNotFoundException;  // indicates that file could not be opened

import java.io.PrintWriter;  //used to print or formatted data

public class BabyNames{  //class name

public static void main(String[] args) throws FileNotFoundException{  //main function body throws FileNotFoundException to indicate if the file cannot be opened

File input_baby = new File("babynames.txt");  //creates object iFile and passes babynames.txt file name to it

File boy_output = new File("boynames.txt");  //creates object of File and passes boynames.txt name to it This file is to store boys names from babynames.txt

File girl_output = new File("girlnames.txt");  //creates object of File & passes  girlnames.txt name to it. To store girls names from babynames

String[] boy_names = new String[100];  //create an array to hold boys names

String[] girl_names = new String[100];  //creates an array to hold girls names

PrintWriter boyNames = new PrintWriter(boy_output);  //create object of PrintWriter for writing the separated boys names to boynames.txt file

PrintWriter girlNames = new PrintWriter(girl_output);  //create object of PrintWriter for writing the separated  girls names to girlnames.txt file

Scanner input = new Scanner(input_baby);  //creates Scanner class object to scan babyname.txt

int i = 0;  

while (input.hasNextLine()){  //checks if the babynames files has next line until the last line of the file

String str = input.nextLine();  //scans the current line

String[] strings = str.split(" ");  //split the line into array of strings/words based on the space " " delimiter

boy_names[i] = strings[1];  //array to store boys names and strings[1] locates the boys names in input file

girl_names[i++] = strings[3];  }  //array to store girls names strings[3] locates the girls names

for(i = 0; i < 100; i++){  //write the separated boys names to boynames.txt file and separated girls names in girlnames.txt file

           boyNames.write(boy_names[i]);

           boyNames.println();

           girlNames.write(girl_names[i]);

           girlNames.println();}  

input.close();  

boyNames.close();  

girlNames.close(); } }

Explanation:

The program has an input file babynames.txt and two text files to store separated boys and girls names. The while loop reads every line of the babynames.txt at each iteration and and splits each line into array of words strings based on the space delimiter. A line from babynames.txt file: 1 Michael 65,275 Jessica 46,470

boy_names[i] = strings[1] This line in loop basically locates boys names from each line of the babynames file. For the line given above. At first iteration of while loop when i=0 then boy_names[i] = strings[1] statement sets 1st index of strings array to the 0-th index of boy_names. Notice that 1st index of strings array is the second word of the above line i.e. Michael. So Michael is stored as 1st element of array boys_name.

girl_names[i++] = strings[3]; locates girls names in the same way as boy_names[i] = strings[1]

strings[3] means 3rd index of strings array Notice that 3rd index of strings array is Jessica.

There are total of 100 boys and 100 girls names in babynames.txt file so for(i = 0; i < 100; i++) this for loop prints these 100 separated boys and girls names in their respective files.

However this program only separates the boys and girls names and not their data such as in this line of input file Michael has data 65,275 and Jessica has 46,470. If you want to add this data into boynames.txt and girlnames.txt files then alter the above code. The altered code is attached.

create an array to store data of boys.

String[] boy_data = new String[100];

Create an array to store data of girls.

String[] girl_data = new String[100];

Now considering the same example 1 Michael 65,275 Jessica 46,470

boy_data[i] = strings[0] + " " + strings[1] + " " + strings[2];  the boy_data array stores data of boys i.e. the elements of 0th 1st and 2nd index. Notice that element at 0th index is the first element element i.e. 1, element at 1st index is Michael and element at 2nd index is 65275. So this is the data of Michael.

girl_data[i++] = strings[0] + " " + strings[3] + " " + strings[4];  }  the girl_data array stores data of girls i.e. the elements of 0-th 3rd and 4th index. Notice that element at 0-th index is the first element element i.e. 1, element at 3rd index is Jessica and element at 4th index is 46,470. So this is the data of Jessica.

Now the outer loop iterates is used to print the separated data of boys and girls. 1st inner loop has an if statement  if(boy_data[j].split(" ")[1].compareTo(boy_names[i]) == 0) which splits the boy_data and compareTo() method compares the first element of boy_data (Michael) to first element of the boy_names array (Michael). If both are same then it write the data i.e.  to boynames.txt 1 Michael 65,275. Same works for the girls too. The program along with its output is attached.

Initialize the list short_names with strings 'Gus', 'Bob', and 'Zoe'. Sample output for the given program:
Gus
Bob
Zoe
1 short_names - "Gus[0]
2 short_names - 'Bob [1]
3 shortt_names - "Zoe[2]
4
5 print (short names[0])
6 print (short names[1])
7 print (short names[2])

Answers

Answer:

Following are the correct code to this question:

short_names=['Gus','Bob','Zoe']#defining a list short_names that holds string value

print (short_names[0])#print list first element value

print (short_names[1])#print list second element value

print (short_names[2])#print list third element value

Output:

Gus

Bob

Zoe

Explanation:

In the above python program code, a list "short_names" list is declared, that holds three variable that is "Gus, Bob, and Zoe".In the next step, the print method is used that prints list element value.In this program, we use the list, which is similar to an array, and both elements index value starting from the 0, that's why in this code we print "0,1, and 2" element value.

Megan was working on an image for a presentation. She had to edit the image to get the style she wanted. Below is the original picture and her final picture. Which best describes how she edited her picture? She cropped the blue background and added contrast corrections. She removed the complex blue background and added contrast corrections. She cropped the blue background and added artistic effects. She removed the complex blue background and added artistic effects.

Answers

Answer:

She removed the complex blue background and added artistic effects.

Explanation:

This is the best answer because both aspects are correct. If Megan were to "Crop" the backgrounds the shape would have changed and she would not have been able to get the whole background without cropping some of the flowers out. Therefore it is not A or C. The pictured change is most definitely artistic effects. So D is the best option.

Answer:

She removed the complex blue background and added artistic effects.

Explanation:

on edg

You are in a rectangular maze organized in the form of M N cells/locations. You are starting at the upper left corner (grid location: (1; 1)) and you want to go to the lower right corner (grid location: (M;N)). From any location, you can move either to the right or to the bottom, or go diagonal. I.e., from (i; j) you can move to (i; j + 1) or (i + 1; j) or to (i+1; j +1). Cost of moving right or down is 2, while the cost of moving diagonally is 3. The grid has several cells that contain diamonds of whose value lies between 1 and 10. I.e, if you land in such cells you earn an amount that is equal to the value of the diamond in the cell. Your objective is to go from the start corner to the destination corner. Your prot along a path is the total value of the diamonds you picked minus the sum of the all the costs incurred along the path. Your goal is to nd a path that maximizes the prot. Write a dynamic programming algorithm to address the problem. Your algorithm must take a 2-d array representing the maze as input and outputs the maximum possible prot. Your algorithm need not output the path that gives the maximum possible prot. First write the recurrence relation to capture the maximum prot, explain the correctness of the recurrence relation. Design an algorithm based on the recurrence relation. State and derive the time bound of the algorithm. Your algorithm should not use recursion

Answers

Answer:

Following are the description of the given points:

Explanation:

A) The Multiple greedy approaches could exist, which could be to reach for the closest emergency diamond, and yet clearly we are going to miss some very essential routes in that case. So, it can make every argument quickly, and seek to demonstrate a reference case for that.

B) An approach to the evolutionary algorithm and its users are going to just have states M x N. But each state (i, j) indicates the absolute difference between the amount of the selected diamond and the amounts of the costs incurred.

DP(i, j) = DimondVal(i, j) + max ((DP(i, j-1)-2), (DP(i-1,j-1)-3))

DP(i, j) is a description of the state.

DimondVal(i, j) is the diamond value at (i j), 0 if there is no diamond available.

This states must calculate the states of M N  and it involves continuous-time for each State to determine. Therefore the amount of time of such an algo is going to be O(MN).

What's the value of this Python expression? ((10 >= 5*2) and (10 <= 5*2))

Answers

Answer:

1 (true)

Explanation:

10 == 10 is valid=> 10 >= 10 is valid => 10 >=(5*2) is valid

10 == 10 is valid=> 10 <= 10 is valid => 10 <=(5*2) is valid

=>  ((10 >= 5*2) and (10 <= 5*2)) is valid => Return 1 or True

C++ PROGRAM THAT DOES THE FOLLOWING:
Problem You Need to Solve for This Lab:
You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should save the data back to the same data file when the program exits.
What Your Program Should Do:
Write an interactive text based menu interface (using a loop) that will allow the user to
 Enter information for a new song
 Display information for all the songs in the database with index for each song
 Remove a song by index
 Search for songs by a certain artist
 Search for songs by a certain album
 Quit

Answers

Answer:

I have updated answer in google

Explanation:

please chek it. I hope it will nice

solve this simple question 1) Let S = {a, bb, bab, abaab} be a set of strings. Are abbabaabab and baabbbabbaabb in S*? Does any word in S* have odd number of b’s?

Answers

Answer: a.

S = {aa ab ba bb}

This clearly shows that that every string that belongs to this language has an even length including 0 length.

This language can be depicted as following

S* = {∧ aa ab ba bb aaaa aaab aaba aabb bbaa . . .}

Regular Expression for this can be

RE = (aa+ab+ba+bb)*

So S* contains all the strings of a's and b's that have even length. This means all strings of even length.

Explanation:

b.

S* contains all possible strings of a's and b's that have length divisible by 3

This means some of the possible strings examples are:

aaa, bbb, aaabbb, aaaaaa, bbbbbb and so on.

Length divisible by 3 means the length of string such as aaa is 3 which is divisible by 3, also  aaaaaa has length 6 which is divisible by 3

This should be something like this:

(( a + b ) ^3)*

For example a^3 = aaa which is divisible by 3

Regular expression can be:

RE of S* = (aaa + bbb)*

For example string bbbbbbbbb has length 9 which is divisible by 3

So the language is

S* = { ∧ aaa bbb aaabbb aaaaaa aaaaaabbb...}

Explanation:

ZigBee is an 802.15.4 specification intended to be simpler to implement, and to operate at lower data rates over unlicensed frequency bands.

a. True
b. False

Answers

Answer:

True

Explanation:

Solution

ZigBee uses unlicensed frequency bands but operate at slower speed or data rates.

ZigBee: This communication is particular designed for control and sensor networks on IEEE 802.15.4 requirement for wireless personal area networks (WPANs), and it is a outcome from Zigbee alliance.

This communication level defines physical and  (MAC) which is refereed to as the Media Access Control layers to manage many devices at low-data rates.

Other Questions
What is the equation, in point-slope form, of the line thatis perpendicular to the given line and passes through thepoint (-4, -3)?2y + 3 = -4(x + 4)y + 3= -1/4x + 4)y + 3 = 1/4x + 4)y + 3 = 4(x + 4) Which is true regarding the graphed function f(x)?O FO) = 3O f/5) = -1Of(3) = 2Of(2)= -2 The Anti-Federalists favored strong state governments because A) states had led the American people to victory in the American Revolution. B) all of the states had already passed bills of rights. C) they believed that was the best way to protect peoples liberty D) they believed states would more strongly resist an attempted takeover by Great Britain. Which of the following proteins would be most soluble in water? A. Silk B. Collagen C. Transport proteins D. Keratin How do you find the amount of electrons for any element? Which of the following represents a coefficient from the expression given?9x 20 + x2 A bag contains 5 blue marbles, 2 black marbles, and 3 red marbles. A marble is randomly drawn from the bag the possibility of not drawing a black marbles is? The probability of drawing a red marble is? simplify the expression (2-5 root 6) times 3 root 2 Simplify the polynomial (7m+5)^2 What is the arithmetic mean between 27 and -3 5p coins weigh approximately 3 grams. What would be the weight of 5 worth of 5p coins?Give your answer in kg. What is the complete factorization of x^2+4x-45? role of media essay PLEASE HELP ME! Why Great Britain's colonies have contributed tothe start of the Industrial Revolution in Great Britain? The working lifetime, in years, of a particular model of bread maker is normally distributed with mean 10 and variance 4. Calculate the 12th percentile of the working lifetime, in years. 51-8; and v=V5i+j. Round to the nearest tenth of a degree.Find the angle between u=65.90c.a.90.4033.30b. 98.50d.Please select the best answer from the choices provided Please help i will mark brainliest! Merry Soy, married, earns a weekly salary of $830 and claims one withholding allowance. By the percentage method, how much income tax will be withheld? (Use tables in the text or the Handbook.) Name one way chemicals can help the environment The percent errors of your experimental values of the specific heats may be quite large. Identify several sources of experimental error.