while循环不循环

时间:2014-06-02 18:22:49

标签: java while-loop

您好我正在练习java并且只学习java几天。我需要减去500000的奖学金金额100000,但我似乎被困在400000并且它不会继续。我的代码有什么问题请有人帮助我。提前致谢。

import java.util.Scanner;
import java.util.LinkedList;

public class Main
{
   public static void main(String [] args)
   {
      Scanner input = new Scanner(System.in);
      Application a = new Application();
      LinkedList lList = new LinkedList();
      boolean bEligible = false;
      int scholarship = 100000;
      int scholarshipAmount = 500000;
      int amount;

      while(scholarshipAmount != 0)
      {
         System.out.println("Please enter name");
         a.setsName(input.nextLine());

         System.out.println("1–Pre Diploma, 2–Diploma, 3–Degree");
         System.out.println("Please enter your Study Level");
         a.setiStudyLevel(input.nextInt());

         System.out.println("Please enter your Personality Score");
         a.setiPersonalityScore(input.nextInt());

         System.out.println("Please enter your Parents Incomee");
         a.setdParentsIncome(input.nextDouble());

         String sName = a.getsName();
         int iStudyLevel = a.getiStudyLevel();
         int iPersonalityScore = a.getiPersonalityScore();
         double dParentsIncome = a.getdParentsIncome();

         if(iPersonalityScore <=90)
         {
            if(dParentsIncome >=3000)
            {
               System.out.println("you are not eligible for scholarship ");
            }
            else
            {
               System.out.println("you are eligible for scholarship ");
               bEligible = true;
            }
         }
         else
         {
            System.out.println("you are eligible for scholarship ");
         }


         System.out.println(sName);
         System.out.println(iStudyLevel);
         System.out.println(iPersonalityScore);
         System.out.println(dParentsIncome);

         amount = scholarshipAmount - scholarship;

         System.out.println(amount);
      }
   }
}

1 个答案:

答案 0 :(得分:6)

您永远不会更改scholarshipAmount金额

你需要这样做

 scholarshipAmount = scholarshipAmount - scholarship;

然后您需要更改此

System.out.println(amount);

System.out.println(scholarshipAmount );
相关问题