+ 7
[PROBLEM SOLVED] loan calculator
i wrote this code for the loan calculator : import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); //your code goes here for(int i=0 ; i<3 ; i++){ int payment= ((amount*10)/100); int remaining = amount - payment ; System.out.println(payment); System.out.println(remaining); amount = remaining ; } } } the code is correct and even the expected outputs turn out correct but the website doesnt accept the code ! any idea why ?
26 Respuestas
+ 34
It would be good to check results in expected output. I mean you can compare your output with the expected output.
You need to get output outside for loop to avoid getting several amounts.
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
int remaining = amount ;
//your code goes here
for(int i=0 ; i<3 ; i++){
int payment= ((amount*10)/100);
remaining = amount - payment ;
//System.out.println(payment);
amount = remaining ;
}
System.out.println(remaining);
}
}
+ 17
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
//your code goes here
for (int x = 0;x < 3;x++) {
amount -= ((amount * 10) / 100);
};
System.out.println(amount);
}
}
//Simple!
+ 6
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
int loan;
//your code goes here
for(int i=1;i<=3;i++)
{
loan =amount/10;
amount-=loan;
}
System.out.println(amount);
}
}
+ 5
Jamie Hershberger the letter i is just a random name of an integer variable. You can use any name you want for that.
for(int Jamie = 0 ; Jamie<months ; Jamie++)
+ 4
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
for(int i=1 ; i<=3 ; i++){
int payment= ((amount*10)/100);
amount -= payment ;
}
System.out.println(amount);
}
}
+ 3
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
//your code goes here
for (int i=0;i<3;i++){
amount-=(amount*0.1);
}
System.out.println(amount);
}
}
+ 2
Here is my answer:
import java.util.Scanner;
public class Programm{
public static void main(String[] args){
Scanner scanner=new Scanner(System.in);
int amount=scanner.nextInt();
int remaining=amount;
for(int i=0;i<3;i++){
//System.out.println("Month number: "+i);
int toPay=(amount*10)/100;
remaining=amount-toPay;
//System.out.println(toPay);
amount=remaining;
}
System.out.println(remaining);
}
}
+ 1
Isn't it better ? Without loop ?it is working fine. Why I need to use loop here ???
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
//your code goes here
int amount1 = amount * 90/100;
int amount2 = amount1 * 90/100;
int amount3 = amount2 * 90/100;
System.out.println(amount3);
}
}
+ 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 loan;
for (int i = 1; i <= 3; i++) {
loan = amount / 10;
amount -= loan;
}
System.out.println(amount);
}
}
+ 1
Simply this code of mine could do for you it's simple and no advanced syntax is used
import java.util.Scanner;
public class program {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
for(int x=0; x<3; x++) {
int remain = amount / 10;
amount = amount - remain;
/* If you want it to display the
Value for each month which
In this case three months
Cause our loop is limited to
Three times "x>3"
You simply type the printing
Part here before this curly brace below
*/
}
System.out.println(amount);
} }
+ 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 i = 0 ;
//your code goes here
if (amount>0){
while(i<3){
amount=amount- (amount*10/100);
i++;
}
System.out.println (amount );
}
}
}
+ 1
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
//your code goes here
int i=1;
while( i<=3){
int payment = ((amount *10)/100);
amount = amount - payment;
i++;
}
System.out.println(" "+amount);
}
}
0
Simba
it WORKED . thank you!
0
Loan Calculator problem
This is right code for this problem my both case got right
import java.util.Scanner;
public class Program {
public static void main(String[]args) {
Scanner scanner = new Scanner(System.in);
int amount = Scanner.nextInt();
//your code goes here
for(int i=0;i <3; i++){
int payment = ((amount*10)/100);
int remaning = amount - payment ;
amount = remaning;
System.out.println(amount);
}
}
This is is giving both conditions true if you don't want to use loop then u can repeat the condition 3 time by writing them and at last conditon you can print amout that is last answer.
If you guys want that program also msg me i will upload that also for you....
By:- ∆√@¥ ♥ Kūmb#à®
0
WORKS!
0
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
//your code goes here
int loan;
for(int i=1;i<=3;i++)
{
loan =amount/10;
amount-=loan;
}
System.out.println(amount);
}
}
0
SIMPLIEST SOLUTION
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
//your code goes here
for(int i=0;i<3;i++)
{
amount-=amount/10;
}
System.out.println(amount);
}
}
0
for (int i=0 ; i<1 ; i++){
int payment= ((amount*10)/100);
int remaining= amount - payment;
//System.out.println(payment);
//System.out.println(remaining);
amount=remaining;
}
{int payment= ((amount*10)/100);
int remaining= amount - payment;
//System.out.println(payment);
//System.out.println(remaining);
amount=remaining;}
int payment= ((amount*10)/100);
int remaining= amount - payment;
//System.out.println(payment);
System.out.println(remaining);
amount=remaining;
simple layout in 3 steps
0
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount= scanner.nextInt();
int payment;
int ramount = amount ;
for(int i=0;i<=2;i++){
payment=(10*amount)/100;
ramount=amount-payment;
amount = ramount;
}
System.out.println(ramount);
}
}
0
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
//your code goes here
int months = 3;
for(int i=0 ; i<months ; i++)
amount = (amount*90/100);
System.out.println(amount);
}
}
this is the right code for calculating loan