Title Description
Write a program that accepts a positive floating-point value and outputs an approximate integer value for that number. If the decimal value is greater than or equal to 5, rounding up, or less than 5, rounding down.
Input Description: Enter a positive floating point value
Output Description: outputs an approximate integer value for this value
Input Example: 5.5
Output Example: 6
Packageprctice01;/*The title description writes out a program that accepts a positive floating-point value and outputs an approximate integer value for that value. If the decimal value is greater than or equal to 5, rounding up, or less than 5, rounding down. Input Description: Enter a positive floating-point numeric output Description: Output the approximate integer value of the value input example: 5.5 Output Example: 6*/ImportJava.util.Scanner; Public classAPPROCIMATEVALUE15 { Public Static voidMain (string[] args) {Scanner in=NewScanner (system.in); floatnum =in.nextfloat (); intTest = (int) num; SYSTEM.OUT.PRINTLN (test); SYSTEM.OUT.PRINTLN (Num-test>=0.5? Test+1: Test); }}
15: Take approximate value approximatevalue