Question
In this program you will be asking the user for a 4 digit number and then your program will output that number in expanded scientific
In this program you will be asking the user for a 4 digit number and then your program will output that number in expanded scientific notation using the format shown below.
Here is your input value in expanded scientific notation:
userInput = (thousDigit * 10e3) + (hundsDigit * 10e2) + (tensDigit * 10e1) + (onesDigit * 10e0)
As an example, if the user inputs 5629, then your program should output the notation:
5629 = (5 * 10e3) + (6 * 10e2) + (2 * 10e1) + (9 * 10e0)
In order to do this, there are a variety of ways you could accomplish this task. However, for purposes of this lab, I am your customer and I am dictating the steps that you should implement. The steps are below:
- Read in a 4 digit integer value from the user and save in a variable called userDigits
- Create four variables, one for each place value in the number, and save the DIGIT that is in that place value into the appropriate variable. i.e. save the hundreds place digit into the hundreds place variable.
- So how do you get just the digit from a place value in the original number? Think about using modulus and division by the place value here. What algorithm can you come up with to separate and save each digit into its variable?
- Use the four variables and the original number to print the output equation as shown above. Be precise in what your output looks like. It should match the formatting above exactly.
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