Question: Exercise 1 : Create a class named Decimals. - Create a default private constructor ( with nothing inside of it ) . - Write a

Exercise 1: Create a class named Decimals.
- Create a default private constructor (with nothing inside of it).
- Write a static method named printDecimalDigits that takes a double as a parameter and does not return anything.
- The method should print out "Digits after decimal point: ". On the next line, print out all the digits after the decimal point on one line separated by spaces (do not include the decimal point). On the line after that, print out the sum of all of the digits after the decimal point.
- Additional rules: You can only use wrapper classes and the String methods: length(), charAt(), indexOf(). You may use at most one loop and there should be no conditional blocks inside of your loop.
\begin{tabular}{|c|c|}
\hline Method Call & Method Output \\
\hline Decimals.printDecimalDigits(37.25); & \begin{tabular}{l}
Digits after decimal point: \\
25\\
Sum: 7
\end{tabular}\\
\hline Decimals.printDecimalDigits(1000); & \begin{tabular}{l}
Digits after decimal point: \\
0\\
Sum: 0
\end{tabular}\\
\hline Decimals.printDecimalDigits(18.3927493038); & \begin{tabular}{l}
Digits after decimal point: \\
3927493038\\
Sum: 48
\end{tabular}\\
\hline
\end{tabular}
Exercise 1 : Create a class named Decimals. -

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 Programming Questions!