課後習題page101.pp3.4

//********************************************************
//  doubleToMaxIntAndMinInt.java   Author: Jayson
//********************************************************

import java.util.Scanner;

public class doubleToMaxIntAndMinInt
{
	//----------------------------------------------------------------
	//  input a double, then print a int smaller than
	//  it (max of those) and print a int bigger than it (min of it)
	//----------------------------------------------------------------
	public static void main(String[] args)
	{
	   int max, min;
	   double number;
	   Scanner scan = new Scanner(System.in);
	   
	   System.out.printf("Please input a double number:");
	   
	   number = scan.nextDouble();
	   
	   scan.close();
	   
	   max = (int)number;
	   min = (int)number + 1;
	   
	   System.out.println(max);
	   System.out.println(min);
	}
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章