Reference no: EM13941426
(The following is exactly how the problem is presented)
import java.util.Scanner;
import java.text.DecimalFormat;
/**
Iteratively computes e^x for a given value x, outputing values at iteration
1 to 10, 50, and 100
*/
public class Ex {
public static void main(String[] args) {
// Make a Scanner to read data from the console
Scanner console = new Scanner(System.in);
// Make a NumberFormat object that we'll use when printing values
// of n in the loop below
DecimalFormat nFormat = new DecimalFormat("000");
// Read in a number for x
System.out.println("Enter a value for x (or a blank line to quit):");
String xString = console.nextLine();
while ((xString != null) && (xString.length() > 0)) {
double x = Double.parseDouble(xString);
// --------------------------------
// ----- ENTER YOUR CODE HERE -----
// --------------------------------
// --------------------------------
// --------- END USER CODE --------
// --------------------------------
// Start over again
System.out.println(
"Enter a value for x (or a blank line to quit):");
xString = console.nextLine();
}
}
}
The value ex can be approximated by the sum:
1 + x + x2/2! + x3/3! + ... + xn/n!
Write a program that takes a value x as input and outputs this sum for n taken to be each of the values 1 to 10, 50, and 100. Your program should repeat the calculation for new values of x until the user says she or he is through. The expression n! is called the factorial of n and is defined as
n! = 1 * 2 * 3 * ... * n
Define variables for the value of n! in the current iteration of the loop. Within the loop, you can then simply update this variable to be equal to the previous value multiplied by the value of the loop iterator. For example, if the loop iterator variable is n and the current factorial value is in variable fact, the following line will update the value of the factorial:
fact = fact * n;
The program should use a DecimalFormat object (local variable nFormat) to format the output. See Section 2.1 for more information on the DecimalFormat class.
Make sure that you use a variables of type double for the calculations in this project
Property management department
: How important is it to have strong processes and procedures in your Property Management department? Why and what are some processes relating to reception and tenants needs and briefly describe them?
|
Discuss specific symptoms children with adhd
: Introduction: Write one to two pages in which you provide a summary of ADHD and discuss specific symptoms children with ADHD might demonstrate in the classroom and during play activities
|
Costs to register and issue securities
: Direct and Indirect combination costs, Costs to register and issue securities.
|
Beta of stock
: A stock has an expected return of 12.2 percent, the risk-free rate is 4 percent, and the market risk premium is 10 percent. What must the beta of this stock be?
|
Use a variables of type double for the calculations
: Write a program that takes a value x as input and outputs this sum for n taken to be each of the values 1 to 10, 50, and 100
|
What is the value of the tax shield
: Hastings Corporation is interested in acquiring Vandell Corporation. Vandell has 1 million shares outstanding and a target capital structure consisting of 30% debt; its beta is 1.20. What is the value of the unlevered firm? What is the value of the t..
|
Different combinations of the two goods
: Consider a consumer who each week purchases two goods, X and Y. The following table shows three different combinations of the two goods that lie on three of her indifference curves-A,B, and C.
|
Capital markets-how does leverage affect cost of equity
: In perfect capital markets, how does leverage affect the cost of equity? a. In perfect capital markets, levered equity's cost increases with the debt-equity ratio. b. In perfect capital markets, leverage increases the cost of levered equity by the co..
|
Combine the four loop problems into one program
: Combine the four loop problems into one program with four distinct methods (the data is in the attached document). For this problem you will write methods, two value returning methods and two void methods.
|