Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Write a program in java, input a floating point number from the keyboard, and then output the integer part of the floating point number
Write a program in java, input a floating point number from the keyboard, and then output the integer part of the floating point number

By directly converting it into an integer, rounding can be completed. The specific code is as follows: import?java.util.Scanner;

public?class?App12?{

public?static?void?main(String[]?args)?{

Scanner?scanner?=?new?Scanner(System.in);

float?f? =?scanner.nextFloat();

//?Take the integer part

int?result?=?(int)f;

System.out. println(result);

}

}