输入没有错误,但是没有输出

问题描述 投票:-1回答:3
   package gradrequirment;
   import java.util.Scanner;
  public class graduation {
public static void main(String[] args) {

此程序显示您是否可以从高中毕业。。

Scanner gpa = new Scanner(System.in);
Scanner math_credit = new Scanner(System.in);
Scanner english_credit = new Scanner(System.in);
Scanner science_credit = new Scanner(System.in);
Scanner socialstudies_credit = new Scanner(System.in);
Scanner service_hours = new Scanner(System.in);
Scanner physed3 = new Scanner(System.in);
Scanner arts3 = new Scanner(System.in);
boolean physed;
boolean art;
boolean hope1;
boolean art1;

我尝试过char的char输入是否可行?

System.out.println("Enter your GPA, service hours, and credits for each class.");
System.out.println("");
System.out.println("Enter GPA:");
double GPA = gpa.nextDouble();
System.out.println("Enter Service Hours:");
int hours = service_hours.nextInt();
System.out.println("Enter Y/N if you have take HOPE.");
char hope = physed3.next().charAt(0);
System.out.println("Enter in How Many Math Credits You Have:");
int math = math_credit.nextInt();
System.out.println("Enter in English Credits:");
int english = english_credit.nextInt();
System.out.println("Enter in Science Credits:");
int science = science_credit.nextInt();
System.out.println("Enter in Social Studies Credits:");
int studies = socialstudies_credit.nextInt();
System.out.println("Enter Y/N if You Have A Fine Art Credit.");
char arts = arts3.next().charAt(0);

所有的布尔值和if-elses似乎都能正常运行。

if (math >= 4)
{
 boolean math1 = true;
}


 else {

  boolean math1 = false;


if (english >= 4)
{
    boolean english1 = true;
}

else {
    boolean english1 = false;


if (science >= 3)
{

boolean science1 = true;
}
else {
    boolean science1 = false;


   if (studies >= 3)
  {
   boolean studies1 = true;
   }
    else {
    boolean studies1 = false;


if (hours >= 100)
{
boolean hours1 = true;
}
else {
    boolean hours1 = false;


    if (GPA >= 2.0)
    {
        boolean gpa1 = true;
    }
    else {
    boolean gpa1 = false;

    if (physed3.next().charAt(0) == (89))
      physed = true;

    else {
    physed = false;

    if (arts3.next().charAt(0) == (89))
        art = true;
    else {
        art = false;


    if (physed == true)
        {
        hope1 = true;
        }
        else {

        hope1 = false;
        }


        if (art == true)
        {
        art1 = true;
        }
        else {

        art1 = false;

最后一个if else语句没有可见错误,但没有输出。

        if(art1 && hope1 && gpa1 && hours1 && gpa1 && studies1 && science1 && english1 && math1 == true)
        System.out.println("You Have Graduated!");

        else
        System.out.println("You Have Not Graduated. Try Harder!");

    gpa.close();
    math_credit.close();
    science_credit.close();
    socialstudies_credit.close();
    english_credit.close();
    service_hours.close();






        {
        }   
        }

        }
        }
    }
}   
}
}
}
 }  
}
}

我对java还是比较陌生,所以我不知道是否有明显的错误。

java eclipse if-statement output java.util.scanner
3个回答
0
投票

0
投票

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.