2021年1月20日星期三

Why is my while loop printing out the same thing each time?

I'm sorry, I know this question is probably asked a million different times every day, but I truly can't find the answer I'm looking for. I'm a beginner in Java (I'm in college and learning a bunch of new languages), and my while loop is printing out the same thing every time.

import java.util.Scanner;    public class Main  {      public static void main(String[] args) {          Scanner scanner = new Scanner(System.in);          System.out.println("What is the loan amount? ");          int amount = scanner.nextInt();          int x = 1;          //your code goes here          while (x < 6){              System.out.println("Month " +x+ ":");                int percent = (amount / 10);              System.out.println("Payment: 10 percent of " +amount+ " = " +percent);                int rAmt = amount - percent;              System.out.println("Remaining amount: " +rAmt);                x++;          }      }  }  
https://stackoverflow.com/questions/65820908/why-is-my-while-loop-printing-out-the-same-thing-each-time January 21, 2021 at 11:48AM

没有评论:

发表评论