5 Replies Latest reply: Mar 9, 2007 4:29 PM by 807599 RSS

    Operator >= cannot be applies to java.util.scanner,int

    807599
      I continue to get this error on this one line (i'll specify it in the code). I'm new to methods/functions so this might just be me being stupid. Any help would be greatly appreciated. Its a bunch of code so I just put what I think to be the relevant parts in. Suffice it to say that the method part of the code works on its own.
      public class Main {
          
          public static long Mydate(Scanner in)
          {
      
              
              String dateImput = " "; //user input variable
              
              long diffMillis = 0;
              
              long diffSeconds = 0;
              
              long diffHours = 0;
             
              long diffDays = 0;
              
              long diffMinutes = 0;   
              
              long expirationLong = 0;
              
              long rideTimeLong = 0;
              
              Date d = new Date(); //declares date "d"
      
              GregorianCalendar rideTime = new GregorianCalendar(); //the time as the person swipes their card
      
              GregorianCalendar expiration = new GregorianCalendar(); //the expiration date of their card
              
              GregorianCalendar cal = new GregorianCalendar();
      
              Date todaysDate = rideTime.getTime(); /*date conversion of gregorian calendar ridetime (I dont think this 
                                                 *is needed, but I'll deal with that later */
              
             System.out.println("Please enter todays date in the format mm/dd/yyyy");
      
              String input = in.next(); // inputs the date from the user
      
              DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); // declares date format "df"
      
             
                  try {            
      
                      d = df.parse(input); //parses the imput into date "d"
                      
                      } catch (ParseException ex) 
                      
                      {
                      ex.printStackTrace();
                                
                      }
                      
                      
       
        
         
          
          expiration.setTime(d); // converts date "d" to gregorian calendar "expiration"
      
          
           expiration.set(Calendar.MINUTE, 00); 
           expiration.set(Calendar.HOUR, 00);
           expiration.set(Calendar.SECOND, 00);
           
           rideTime.set(Calendar.MINUTE, 00);
           rideTime.set(Calendar.HOUR, 00);
           rideTime.set(Calendar.SECOND, 00);
      
      
          diffMillis = expiration.getTimeInMillis()-rideTime.getTimeInMillis(); //subtract expiration - ridetime
      
          diffSeconds = diffMillis / (1000); //get seconds
      
          diffMinutes = diffSeconds / (60); //get minutes
      
          diffHours = diffMinutes / (60); //get hours
      
          diffDays = diffHours / (24) + 1; //get days
      
          System.out.println("You have" + " " + diffDays + " " + "days left on your card");
      
             
          return diffDays;
          
        
      
          
          }
          
          /** Creates a new instance of Main */
          public Main() {
              
              
              
              
          }
          
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args, Scanner diffDays) throws FileNotFoundException 
                  
          {
        
             Scanner in = new Scanner(System.in);
          String cardtype = "";
          int date = 0;
          String yes = " ";
          int expirationDate = 0;
          int money = 0;
          int times = 0;
          int timeNow = 0;
          int timeThen = 0;
          double rand = Math.random ();
          int upper = 10;
          double result = 0;
          result = upper * rand;
          String timeInteger;
          String hours;
          String minutes;
          int integerHours;
          int integerMinutes;
                 
          
         
          //Type of Card
          if(result > 2){
              System.out.println("Enter your Card Type: regular, single ride, student, senior, transfer or monthly");
              
              cardtype = in.nextLine();
            
              if(cardtype.equals("regular"))//REUGLAR TYPE OF CARD
              {  
                  Mydate(diffDays);
                          
                          if( diffDays >= 1) //THIS IS WHERE IT GIVES THE ERROR
                          {
                          System.out.println("How much money is on the card");
      Message was edited by:
      Jaked