public class Main {
public static void main(String[] args) {
double a = 100.235;
System.out.println((int)a);
}
}
NOTE:
- Didn't use Scanner as there is no input to ask from the user.
- Used double as we needed to change double.
- Used System.out.println((int)a); to change double to int.
- Double and int are different because Double can contain decimal value but int can not. For example : double is 100.235 then int will be 100 as it cant contain decimal values.
No comments:
Post a Comment