top of page
Click here to go to the home page of AskTheCode.

Certain digit in Java | Ask The Code

Team ATC

Updated: Mar 9, 2021

Basic Java Programming | Display certain digit in Java | AskTheCode

 

Problem:

Java program to get the certain digit of a number given by the user.


Input sample:

5.12323

Output Sample:

5


Code:

import java.util.Scanner;
import java.text.DecimalFormat;

public class certain_Digit{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		DecimalFormat df = new DecimalFormat("#");
		float num = scan.nextFloat();

		System.out.println(df.format(num));
	}
}

Recent Posts

See All

Commentaires


bottom of page