Question: In this task you have been given code that asks the user to enter 5 decimal numbers, and stores these in an array. This time

In this task you have been given code that asks the user to enter 5 decimal numbers, and stores these in an array.
This time these numbers represent the balance of a bank account at monthly intervals. The first element in the array is the balance of the bank account at the start of the first month, the second element is the balance of the account at the start of the 2nd month, and so on.
Your task is to analyse the data in the array and print out one of the following options:
"You are saving consistently, well done!" if the balance of the account consistently increases from month to month.
"Your savings are dwindling" if the balance of the account consistently decreases from month to month.
"Your savings have fluctuated" if the balance of the account does not consistently increase or decrease from month to month.
Hint 1:
To tell if the bank account is consistently increasing, you would need to confirm that the 2nd element is greater than the 1st, the 3rd element is greater than the 2nd, the 4th element is greater than the 3rd, and the 5th element is greater than the 4th. In other words, you need to compare every adjacent pair of elements in the array. You can do this as one big boolean expression. It's not that bad since there are only 4 adjacent pairs to compare.
Hint 2:
Your approach for telling if the bank account is consistently decreasing would also focus on comparing adjacent pairs of elements in the array, and could again be done as one big boolean expression.
 In this task you have been given code that asks the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!