Write a program that prompts the user to input any digit then swap the position of the first and the last digit. Next, the user will be prompt to select what arithmetic operation he/she want to employ on the first and last digit based on the following choices: 1. Sum of their square 2. Product of their square root
Write a program that prompts the user to input any digit then swap the position of the first and the last digit. Next, the user will be prompt to select what arithmetic operation he/she want to employ on the first and last digit based on the following choices:
1. Sum of their square
2. Product of their square root
3. Square of their product
The output will display the result of the arithmetic operation followed by the digit with a swapped position of “first” and “last” digit. Then finally display the equivalent uppercase alphabet for the first digit and lowercase alphabet for the last digit respectively after swapping.
Note:
1. If the last digit of the inputted digit from the user is zero, it must display that there is no equivalent alphabet for that digit.
2. If the user chooses arithmetic operation No.2, format the output to three decimal places
TEST CASES:
If a user inputs a digit and choose arithmetic operation No.1:
Input any number: 97834
Select an arithmetic operation that you want to implement for the 'first' and 'last' digit:
1. Sum of their square
2. Product of their square root
3. Square of their product
Choose between 1 - 3: 1
The Sum of their square is 97
The number after swapping the first and last digits are: 47839
The equivalent uppercase alphabet for the first digit, 4, after swapping is D.
The equivalent lowercase alphabet for the last digit, 9, after swapping is i.
If a user input a digit where the last digit is a zero:
Input any number: 67450
Select an arithmetic operation that you want to implement for the 'first' and 'last' digit:
1. Sum of their square
2. Product of their square root
3. Square of their product
Choose between 1 - 3: 2
The Product of their square root is 0.000
The number after swapping the first and last digits are: 7456
The first digit after swapping is 0. No equivalent alphabet!
The equivalent lowercase alphabet for the last digit, 6, after swapping is f
Step by step
Solved in 2 steps with 1 images