samedi 19 octobre 2019

There is no error on input, but no output

   package gradrequirment;
   import java.util.Scanner;
  public class graduation {
public static void main(String[] args) {

this programs shows if you can graduate or not from high school..

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;

Could it be possible that the char input i tried dosent work?

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);

all of the booleans and if-elses seem to function correctly.

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;

there is no visible error with the last if else statement, yet there is no output.

        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();






        {
        }   
        }

        }
        }
    }
}   
}
}
}
 }  
}
}

I am relatively new to java, so i do not know if there is an obvious mistake.

Aucun commentaire:

Enregistrer un commentaire