package jike211.why;
import java.util.Scanner;
/**
* Name: WHY
* text: 输入一个double型数,输出该数的整数部分和小数部分
* @date:2023/12/17
*/
public class pro11 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入一个double型数:");
double number = scanner.nextDouble();
int intPart = (int) number; // 获取整数部分
double malPart = number - intPart; // 获取小数部分
System.out.println("整数部分:" + intPart);
System.out.println("小数部分:" + malPart);
}
}
11-03
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)