Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Print out an approximation of the mathematical constant 1. You must compute an approximation of , accurate out to at least two digits past the

Print out an approximation of the mathematical constant 1. You must compute an approximation of , accurate out to at least two digits past the decimal point, using the following inefficient) formula: 1 1 1 1 1 = 4x + 5 7 9 DO NOT just print out a String-literal of an approximation, i.e., DO NOT JUST DO THIS: + 3 -+...). System.out.println(\"3.14159265359\"); Instead, compute the above expression out to as many terms as it takes to get at least two digits past the decimal point correct. You cannot use explicit type casting for computing your approximation of 2. Prompt the user to which digit past the decimal point in your approximation that they would like for your program to print out. 3. Print out the requested digit, just by itself on its own line. Your program must print out the correct digit (relative to your approximation of 7, out to the fifteenth digit past the decimal point (the first digit past the decimal point will be counted as digit 1). See the Hints section. 4. Do not do any computation steps inside of print statements. 5. Every line of code in your program must be less than or equal to 78 characters in width. Hints: Assuming something is an integer type (int or long), then the expression something % 10 evaluates to the rightmost digit of something. The expression something * 10 evaluates to a number comprised of the digits of something shifted left one position, with a 0 occupying the rightmost digit position. You can and should use Math.pow to compute a power of ten, perhaps based on user in- put, like this: Math.pow(10, ???); Just be careful, because the previous call to Math.pow evaluates to a double. Sample runs: 3.1493444751246202 Which digit past the decimal point do you want? 1 1 3.1493444751246202 Which digit past the decimal point do you want? 7 4 3.1493444751246202 Which digit past the decimal point do you want? 10 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

Discuss Machiavellis importance to the history of psychology.

Answered: 1 week ago