3 Replies - 8292 Views - Last Post: 16 September 2010 - 08:17 PM Rate Topic: -----

#1 Chlose  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 06-December 09

The operator || is undefined for the argument type(s) int, int

Posted 16 September 2010 - 08:02 PM

So im getting the above error, and i wanted to know why and, if possible, how to fix it. Also, sorry about the really long code.
import java.util.Scanner;
import java.util.InputMismatchException;

public class AiubA07{
    
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        //boolean festival = false;
        //boolean sunday = false, monday = false, tuesday = false, wednesday = false, thursday = false, friday = false, saturday = false;
        int day;
        String s1 = " drink";
        String s2 = " duel";
        String s3 = " gamble";
        String s4 = " pillage";
                
        try{
        System.out.println("Please enter the current Bleegian day of the month: ");
        day = s.nextInt();
        if(day > 27 || day < -27){
            System.out.println("Sorry, but " + day + " is not a valid day of the month.");
        }
        else{
        switch(day){
            case 0:
                System.out.println("Today is (Day " + day + ") is festival");
                System.out.println("You may: " + s1 + "," + s2 + "," + s3);
                break;
            case 1 || -27:
                if(day == -27){
                day = 1;
                System.out.println("Today is (Day " + day + ") is Monday");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4);
            }
                else{
                System.out.println("Today is (Day " + day + ") is Monday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");
                break;
                }
            case 2 || -26:
                if(day == -26){
                day = 2;
                System.out.println("Today is (Day " + day + ") is Tuesday.");
                System.out.println("You may: " + s4 + ".");
            }
                else{
                System.out.println("Today is (Day " + day + ") is Tuesday.");
                System.out.println("You may: " + s4 + ".");
                }
                break;
            case 3 || -25:
                if(day == -25){
                day = 3;
                System.out.println("Today is (Day " + day + ") is Wednesday.");
                System.out.println("You may: " + s1 + "," + s4 + ".");
                break;
            }                
                else{
                System.out.println("Today is (Day " + day + ") is Wednesday.");
                System.out.println("You may: " + s1 + "," + s4 + ".");
                break;
                }
            case 4 || -24:
                if(day == -24){
                day = 4;
                System.out.println("Today is (day " + day + ") is Thursday.");
                System.out.println("You may: " + s3 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Thursday.");
                System.out.println("You may: " + s3 + ".");
                break;
                }
            case 5 || -23:
                if(day == -23){
                day = 5;
                System.out.println("Today is (day " + day + ") is Friday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Friday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4  +".");
                break;
                }
            case 6 || -22:
                if(day == -22){
                day = 6;
                System.out.println("Today is (day " + day + ") is Saturday.");
                System.out.println("You may: " + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Saturday.");
                System.out.println("You may: " + s3 + "," + s4 + ".");
                break;
                }
            case 7 || -21:
                if(day == -21){
                day = 7;
                System.out.println("Today is (day " + day + ") is Sunday.");
                System.out.println("You may: " + s1 + "," + s2 + "," + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Sunday.");
                System.out.println("You may: " + s1 + "," + s2 + "," + s3 + "," + s4 + ".");
                break;
            }
            case 8 || -20:
                if(day == -20){
                day = 8;
                System.out.println("Today is (day " + day + ") is Monday.");
                System.out.println("You may: " + s3 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Monday.");
                System.out.println("You may: " + s3 + ".");
                break;
            }
            case 9 || -19:
                if(day == -19){
                day = 9;
                System.out.println("Today is (day " + day + ") is Tuesday.");
                System.out.println("You may: " + s1 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Tuesday.");
                System.out.println("You may: " + s1 + "," + s4 + ".");
                break;
            }
            case 10 || -18:
                if(day == -18){
                day = 10;
                System.out.println("Today is (day " + day + ") is Wednesday.");
                System.out.println("You may: " + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Wednesday.");
                System.out.println("You may: " + s3 + "," + s4 + ".");
                break;
            }
            case 11 || -17:
                if(day == -17){
                day = 11;
                System.out.println("Today is (day " + day + ") is Thursday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Thursday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");
                break;
            }
            case 12 || -16:
                if(day == -16){
                day = 12;
                System.out.println("Today is (day " + day + ") is Friday.");
                System.out.println("You may: " + s3 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Friday.");
                System.out.println("You may: " + s3 + ".");
                break;
            }
            case 13 || -15:
                if(day == -15){
                day = 13;
                System.out.println("Today is (day " + day + ") is Saturday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Saturday.");
                System.out.println("You may: " + s1 + "," + s2 + "," + s3 + "," + s4 + ".");
                break;
            }
            case 14 || -14:
                if(day == -14){
                day = 14;
                System.out.println("Today is (day " + day + ") is Sunday.");
                System.out.println("You may: " + s2 + "," + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Sunday.");
                System.out.println("You may: " + s2 + "," + s3 + "," + s4 + ".");
                break;
            }
            case 15 || -13:
                if(day == -13){
                day = 15;
                System.out.println("Today is (day " + day + ") is Monday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Monday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");
                break;
            }
            case 16 || -12:
                if(day == -12){
                day = 16;
                System.out.println("Today is (day " + day + ") is Tuesday.");
                System.out.println("You may: " + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Tuesday.");
                System.out.println("You may: " + s4 + ".");
                break;
            }
            case 17 || -11:
                if(day == -11){
                day = 17;
                System.out.println("Today is (day " + day + ") is Wednesday.");
                System.out.println("You may: " + s1 + "," + s2 + "," + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Wednesday.");
                System.out.println("You may: " + s1 + "," + s2 + "," + s3 + "," + s4 + ".");
                break;
            }
            case 18 || -10:
                if(day == -10){
                day = 18;
                System.out.println("Today is (day " + day + ") is Thursday.");
                System.out.println("You may: " + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Thursday.");
                System.out.println("You may: " + s3 + "," + s4 + ".");
                break;
            }
            case 19 || -9:
                if(day == -9){
                day = 19;
                System.out.println("Today is (day " + day + ") is Friday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Friday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");
                break;
            }
            case 20 || -8:
                if(day == -8){
                day = 20;
                System.out.println("Today is (day " + day + ") is Saturday.");
                System.out.println("You may: " + s3 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Saturday.");
                System.out.println("You may: " + s3 + ".");
                break;
            }
            case 21 || -7:
                if(day == -7){
                day = 21;
                System.out.println("Today is (day " + day + ") is Sunday.");
                System.out.println("You may: " + s1 + "," + s2 + "," + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Sunday.");
                System.out.println("You may: " + s1 + "," + s2 + "," + s3 + "," + s4 + ".");
                break;
            }
            case 22 || -6:
                if(day == -6){
                day = 22;
                System.out.println("Today is (day " + day + ") is Monday.");
                System.out.println("You may: " + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Monday.");
                System.out.println("You may: " + s3 + "," + s4 + ".");
                break;
            }
            case 23 || -5:
                if(day == -5){
                day = 23;
                System.out.println("Today is (day " + day + ") is Tuesday.");
                System.out.println("You may: " + s1 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Tuesday.");
                System.out.println("You may: " + s1 + "," + s4 + ".");
                break;
            }
            case 24 || -4:
                if(day == -4){
                day = 24;
                System.out.println("Today is (day " + day + ") is Wednesday.");
                System.out.println("You may: " + s3 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Wednesday.");
                System.out.println("You may: " + s3 + ".");
                break;
            }
            case 25 || -3:
                if(day == -3){
                day = 25;
                System.out.println("Today is (day " + day + ") is Thursday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Thursday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");
                break;
            }
            case 26 || -2:
                if(day == -2){
                day = 26;
                System.out.println("Today is (day " + day + ") is Friday.");
                System.out.println("You may: " + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Friday.");
                System.out.println("You may: " + s3 + "," + s4 + ".");
                break;
            }
            case 27 || -1:
                if(day == -1){
                day = 27;
                System.out.println("Today is (day " + day + ") is Saturday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");
                break;
            }
                else{
                System.out.println("Today is (day " + day + ") is Saturday.");
                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");
                break;
            }
        }
      }
        }catch (InputMismatchException e) {
      System.out.println("You must enter a number. Please try again.");
      }
   }
}


Is This A Good Question/Topic? 0
  • +

Replies To: The operator || is undefined for the argument type(s) int, int

#2 Dogstopper  Icon User is online

  • The Ninjaducky
  • member icon



Reputation: 2874
  • View blog
  • Posts: 11,045
  • Joined: 15-July 08

Re: The operator || is undefined for the argument type(s) int, int

Posted 16 September 2010 - 08:09 PM

It's giving you errors because you simply cannot do it that way...Do it like this:
case 27:
case -1:
    /// Stuff
    break;



For all of those.
Was This Post Helpful? 1
  • +
  • -

#3 Chlose  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 06-December 09

Re: The operator || is undefined for the argument type(s) int, int

Posted 16 September 2010 - 08:14 PM

Just to confirm, it would look like this?
case -27:
case 1:

                if(day == -27){

                day = 1;

                System.out.println("Today is (Day " + day + ") is Monday");

                System.out.println("You may: " + s1 + "," + s3 + "," + s4);

            }

                else{

                System.out.println("Today is (Day " + day + ") is Monday.");

                System.out.println("You may: " + s1 + "," + s3 + "," + s4 + ".");

                break;

                }

This post has been edited by Chlose: 16 September 2010 - 08:15 PM

Was This Post Helpful? 0
  • +
  • -

#4 Dogstopper  Icon User is online

  • The Ninjaducky
  • member icon



Reputation: 2874
  • View blog
  • Posts: 11,045
  • Joined: 15-July 08

Re: The operator || is undefined for the argument type(s) int, int

Posted 16 September 2010 - 08:17 PM

Yeap. That's it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1