logotransparent.png

Legion of Learners

www.lol-101.com

  • Home

  • Classrooms

  • Courses

  • About Us

    • Executive Team
    • Board Members
  • Resources

  • More

    Use tab to navigate through the menu items.
    To see this working, head to your live site.
    • Categories
    • All Posts
    • My Posts
    kevinzhao183
    May 16, 2020

    Class 1 HW 5/16

    in Java Question Bank

    https://codingbat.com/prob/p186672


    Solve this problem, then comment your solution.

    8 comments
    0
    angelazhong12
    May 17, 2020

    public boolean only14(int[] numbers) {

    int index = 0;


    boolean only1or4 = true;

    while(index <= numbers.length - 1){

    int a = numbers[index];

    switch (a){

    case 1:

    case 4:

    break;


    default:

    only1or4 = false;

    }

    index = index + 1;

    }

    if( only1or4 == true)

    return(true);

    else

    return(false);

    }


    0
    mwmaxwang3131
    May 22, 2020


    richardalexanderyu
    May 22, 2020

    public boolean only14(int[] nums) {

    boolean isTrue = true;

    for (int i = 0; i < nums.length; i++) {

    if (nums.length[i] ? = 1; nums.length[i] ! = 4;)

    isTrue = false;

    }

    return isTrue;

    }


    0
    richardalexanderyu
    May 22, 2020

    it kinda works

    0
    mwmaxwang3131
    May 23, 2020

    stop copying me XD

    0
    ce_xu
    May 23, 2020

    public boolean only14(int[] nums) {

    for(int i=0; i<nums.length; i++){

    if (nums[i]==1);

    else if (nums[i]==4);

    else return false;

    }

    return true;

    }

    0
    mwmaxwang3131
    May 23, 2020

    did u copy me lol

    0
    agnes.jw1286
    May 23, 2020

    public boolean only14(int[] nums) {

    for(int i = 0; i < nums.length; i++) {

    if(nums[i] == 1 && nums[i] == 4){

    return true;

    }

    }

    else return false;

    }

    }



    0
    8 comments

    Questions? Email us at legionoflearners@gmail.com or join our WeChat group!

    • lol-101dotcom

    ©2020 Legion of Learners