Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
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 Respostas
+ 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
ŠŠ°, Ń
Š¾ŃŠ¾ŃŠ¾, ŃŃŠæŠ°Š½ŃŠ» ŠŗŠ°Šŗ Š²ŃŠµŠ³Š“Š°/