0
Problem vs validation of java course, 2-nd step, final solution 6 months credit calculator.
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double amount = scanner.nextInt(); int rest; for (int i = 0; i < 6; i++) { double percents = ((amount / 100.0) * 10.0); amount -= percents; if (i == 5) { rest = (int) (amount); System.out.println(rest); } } } }
3 Antworten
+ 1
What exactly are you trying to do?
Can you give an example of an output.
And
if you're declaring amount as double why not do scanner.nextDouble();
Would also be better if u declare percents outside the for loop, this way your not constantly re-declaring it.
you don't need that if(i==5)
You can just do println outside the for loop.
+ 1
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
int rest;
for (int i = 0; i < 6; i++) {
double percents = ((amount / 100.0) * 10.0);
amount -= percents;
rest = amount;
if (i == 5) {
System.out.println(rest);
}
}
}
}
Successfully completed with this code! T. Y for feedback
0
Hi. First thank you for reaction.!
I must logic some code, to count credit, for example : from given 20000 i must pay 6 months - 10% from each rest. Program must calculate rest from 20000 after 6 months. In int result.
Output throws 5 tests, tests 1.2.5 os green (so ok), but tests 3 and 4 not successfully (locket to view, red)