Question
The Government of India recently demonetized the existing currency notes of 1000 and 500 denominations and issued new currency notes instead in 2000 and 500
The Government of India recently demonetized the existing currency notes of 1000 and 500 denominations and issued new currency notes instead in 2000 and 500 denominations. People holding the old currency notes needed to exchange them for the new currency notes at bank branches. For this homework, we will assume that the bank will use the least number of notes principle, i.e., it will first calculate the 2000 denomination notes first, and the remaining amount, if any, as 500 denomination notes.
Program the Bank calculation using the following guidelines.
a.Create a package named cs520.hw1.part1
b.Create a class named Demonetize under the above package with the main method.
Create a package named cs520.hw1.part1 b.
Create a class named Demonetize under the above package with the main method.
c. The code in the main method should do the following:
i. Prompt the user for a string input value for the number of old 1000 notes and store it in a variable named input1.
ii. Convert the string to an integer and store it in the variable named thousands. You can assume that the user enters a valid integer number (>= 0)
iii. Prompt the user for a string input value for the number of old 500 notes and store it in a variable named input2.
iv. Convert the string to an integer and store it in the variable named fiveHundreds. You can assume that the user enters a valid integer number (>= 0)
v. Calculate the total amount to be converted to the new notes using the above two inputs and store the value into an integer variable.
vi. Print the the above value to the console.
vii. Declare the integer variables named newTwoThousands, and newFiveHundreds.
viii. Declare another integer variable named remainingAmount.
ix. Compute the newTwoThousands and the remainingAmount. Print the information to the console.
x. Compute the newFiveHundreds. Print the information to the console.
xi. Using a message dialog, show the summary of the above values to the user.
Part2 (60 Points) The Euler constant, e, is computed by the following series: = + ! )
For example, if n = 2, = 1 + 1 1! + 1 2! = 2.5 If n = 5, = 1 + 1 1! + 1 2! + 1 3! + 1 4! + 1 5! = 2.716666667 If n = 12, = 1 + 1 1! + 1 2! + 1 3! + 1 4! + 1 5! + 1 6! + 1 7! + 1 8! + 1 9! + 1 10! + 1 11! + 1 12! = 2.718281828
Program the computation of the Euler constant using a loop for a given value of n using the following instructions:
a.Create a package named cs520.hw1.part2
b.Create a class named EulerConstant under the above package with the main method.
c. Write the static method, compute, that takes the number n as its argument. The code for this method should use a loop to calculate the result using the formula shown in the above equation. The method returns the computed result. Reuse the factorial computed in the previous iteration for the next iteration, i.e., do not explicitly compute each factorial in each iteration of the loop. In each iteration, print the intermediate results as shown in the sample output.
d.The code in the main method should do the following:
i. Invoke the method, compute, for n = 2, and store the result into the variable, result1.
ii. Print the result to the console.
iii. Invoke the method, compute, for n = 5, and store the result into the variable, result2.
iv. Print the result to the console.
v. Invoke the method, compute, for n = 12, and store the result into the variable, result3.
vi. Print the result to the console.
vii. Print the difference between result2 and result1, and result3 and result2. The double values are printed to 9 decimal places using the printfs %.9f format
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started