+ 1
1.How to add a feature that will collect custom input. 2.How to convert double to int
I want to solve the problem of "financial calculus https://code.sololearn.com/ch2pjH47aHix/?ref=app
2 Réponses
+ 6
You can see list of input methods for different types here :
https://www.sololearn.com/learn/Java/2220/
Btw it would be good if you recheck the for loop lesson.
https://www.sololearn.com/learn/Java/2147/?ref=app
- 1
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
float inp = sc.nextFloat();
int n = (int) inp;
System.out.print(n);
}
}
use scanner class for input and see "int n = (int) inp;" to convert float in int