【发布时间】:2014-06-08 15:16:56
【问题描述】:
我需要用 Java 开发奖学金申请。我需要在输出中打印成功的应用程序。
如果我换第二个人,为什么这段代码中的计数器不会增加?
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;
int scholarshipAmount = 500000;
int setiStudyLevel;
int counter;
while(scholarshipAmount != 0)
{
counter = 1;
System.out.println("");
System.out.println("**Welcome to scholarship applications offered by Smart Foundation**");
System.out.println("");
System.out.println("");
System.out.println("Please Enter Your Name");
a.setsName(input.next());
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 Income");
a.setdParentsIncome(input.nextDouble());
String sName = a.getsName();
int iStudyLevel = a.getiStudyLevel();
int iPersonalityScore = a.getiPersonalityScore();
double dParentsIncome = a.getdParentsIncome();
if (iStudyLevel == 1)
{
scholarship = 15000;
scholarshipAmount = scholarshipAmount - scholarship;
}
else if (iStudyLevel == 2)
{
scholarship = 50000;
scholarshipAmount = scholarshipAmount - scholarship;
}
else if (iStudyLevel == 3)
{
scholarship = 500000;
scholarshipAmount = scholarshipAmount - scholarship;
}
System.out.println("");
System.out.println("");
System.out.println("*****Result*****");
System.out.println("Name:"+sName);
System.out.println("1–Pre Diploma, 2–Diploma, 3–Degree");
System.out.println("Study Level:"+iStudyLevel);
System.out.println("Personality Score:"+iPersonalityScore);
System.out.println("Parents Income:"+dParentsIncome);
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("");
System.out.println( "RM"+(scholarshipAmount)+" left!!");
System.out.println("");
if (scholarshipAmount <= 0)
{
System.out.println(" Scholarship Quota is Full!");
}
counter++;
System.out.println(counter);
}
}
}
【问题讨论】:
标签: java while-loop counter