Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help solve this using JAVA! Show me the OUTPUT also. Thank you in advance

ID: 3734589 • Letter: P

Question

Please help solve this using JAVA! Show me the OUTPUT also.
Thank you in advance! Please help solve this using JAVA! Show me the OUTPUT also.
Thank you in advance! Please help solve this using JAVA! Show me the OUTPUT also.
Thank you in advance!

a/Local/Packages/Microsoft.MicrosoftEdge 8wekyb3d8bbwe/TempState/Downloads/nu 1.1 Count Digits We'll start out with something we've done in class before. Write a function countDigits which takes in an int num, which will return the number of digits in num. For example countDigits should evaluate to: . 1 for numbers 0-9, 2 for numbers 10-99, 3 for numbers 100-999, etc Remember, use repeated division by 10 to calculate the number of digits in num. (There's also a tricky solution using logarithms that avoids the repeated division!) 1.2 nth Digit Back Write a method nthDigitBack hich takes in two ints, n and num. This method finds the nth lowest ordeuldigit in num. In other words, nthDigitBack returns the nth digit from the right. The rightmost digit is considered the oth digit back. nthDigitBack should evaluate to 0 for digits out of range (so if you ask for the 1000th digit back of 7546, nthDigitBack will return 0). Here are some example method calls of nthDigitBack nthDigitBack (0, 123) 3 nthDigitBack (1,123) 2 ·nthDigitBack (2,123) 1 e nthDigitBack (3,123) 0 8 ·nthDigitBack (3,18023)

Explanation / Answer

Ans1.1: ---

//given is the java program to count number of digits in in given integer. It takes integer as command line input.

import java.util.*;

import java.lang.*;

import java.io.*;

class CountDigit

{

private static Scanner sc;

public static void main (String[] args) throws java.lang.Exception

{

int Num, Count=0;

sc = new Scanner(System.in);

System.out.println(" Please Enter any Number: ");

Num = sc.nextInt();

while(Num > 0) {

Num = Num / 10;

Count = Count + 1;

}

System.out.format(" Number of Digits in a Given Number = %d", Count);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote