0

code is for loan calculator question in java , everything seems perfect, no compile errors, but this app isn't saying so,help

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(); //your code goes here int i = 1; int j = 0; System.out.println(); while( i != 7){ j = a/10; if(a%10 >= 5){j = j + 1;} a = a - j; i++; } System.out.println( a); }}

2nd Dec 2020, 7:11 PM
Shubham Bawner
Shubham Bawner - avatar
10 Respuestas
+ 1
In the short form case it happening automatic type casting but later need manual type cast because destination is of int type and resulted value is double value.. I came to know, its short form advantage.. Do like this : a=(int)(a*0.9);
3rd Dec 2020, 11:36 AM
Jayakrishna 🇮🇳
+ 3
After seeing the description, you need to round up the value of j. So Shubham Bawner use if(a%10>0) j =j+1 ;
2nd Dec 2020, 10:32 PM
Jayakrishna 🇮🇳
+ 2
Can you add problem description or link..? BTW, is there asked to put a new line? If not remove, System.out.println(); and try.
2nd Dec 2020, 8:23 PM
Jayakrishna 🇮🇳
+ 1
I think that's the task: https://www.sololearn.com/coach/949?ref=app. But I cannot understand the idea behind your code Shubham Bawner.
2nd Dec 2020, 9:10 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
Thanks lot all I got the solution but other problem arises as I did What is difference in a *= b& a=a*b
3rd Dec 2020, 4:07 AM
Shubham Bawner
Shubham Bawner - avatar
+ 1
Is it related to this question..? BTW no difference. a = a*b ; it's short form is a *= b;
3rd Dec 2020, 11:23 AM
Jayakrishna 🇮🇳
0
That's what I say But former works n later dosnt
3rd Dec 2020, 11:25 AM
Shubham Bawner
Shubham Bawner - avatar
3rd Dec 2020, 11:28 AM
Shubham Bawner
Shubham Bawner - avatar
0
Have a look in this code
3rd Dec 2020, 11:29 AM
Shubham Bawner
Shubham Bawner - avatar
3rd Dec 2020, 5:22 PM
Shubham Bawner
Shubham Bawner - avatar