0
Favorite ";"
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); int x = 20000; int b = 18000; int c = 16200; for(int x%10; b%10; c%10){ System.out.println(c); } /* 1 - 18000 2 - 16200 3 - 14580 */ switch(amount){ case 1: System.out.print(18000); break; case 2: System.out.print(16200); break; case 3: System.out.print(14580); break; } } } Where I didn't put ";", I can't find it ;)
29 Antworten
+ 1
Геобс Акк
Use for loop till 3 iteration and inside loop get 10% of amount then subtract from amount then assign to amount.
Finally print amount outside tha loop
10% of 20000 = 2000
now 20000 - 2000 = 18000
so amount = amount - amount * 10 / 100;
write this inside loop
+ 1
I think he is trying to solve Loan Calculator Project
+ 1
Геобс Акк
So the formula is
amount = amount - amount * 10 / 100;
Write this inside for loop and loop will work till i < 3
Outside the loop print amount
+ 1
Геобс Акк
I said use for loop and use that formula. No need to write Hard Code logic
+ 1
Геобс Акк
That is not right. You have to learn how to use loops
for(int x = 0; x < 3; x++) {
amount = amount - amount * 10 / 100;
}
System.out.println(amount);
+ 1
Тебе надо не числа подставлять в программу, а переменные
+ 1
A question without a context !!
0
int x%10; c%10 what these means?
0
I wanted to write down the percentage of the debt digit x
0
percent_10 = (x/100)*10
0
In your loop,
int x%10; is invalid statement.
If on corrected , when b%10 is 0 then only loop stops..
c%10 has no effect statement.
" Percentage of debt digit x " Not understood what do you mean?
What is the purpose of you for loop...
0
Jayakrishna🇮🇳 he wants to take a percentage of the number, only it is not clear how much? 10% or 90%?
0
ПроцентОтЧисла = (Число : 100) * х, где х - это количество процентов, которые нам нужны. по сути мы полное число делим на 100, узнаем, чему равен 1%, затем умножаем на кол-во %, которое нам необходимо
0
10 percent
0
Yes
0
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
percent_10 =20000 - (20000/100)*10;
System.out.println(Month1);
percent_10 =18000 - (18000/100)*10;
System.out.println(Month2);
percent_10 =16200 - (16200/100)*10;
System.out.println(Month3);
}
}
What did I do wrong?
0
Yes, ok, I'll try
0
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
for (20000-20000/100*10 ; i<3);
System.out.println(Month1);
for (18000-18000/100*10 ; i<3);
System.out.println(Month2);
for (16200-16200/100*10 ; i<3);
System.out.println(Month3);
}
}
0
Does not work/
0
Да, хорошо, тупанул как всегда/