How do i make it so every number that is next to a zero divides by two?

zero divided by a number
1/0 = infinity
5 divided by 0
why any number divided by zero is infinity
divide by zero meme
0/1 is equal to
1/0 is infinity or not defined
100 divided by 0

Everything I have tried so far divides the code by 2 and it does it twice for some reason.

CSP-ARRAY An array inhabitant represents cities and their respective populations. For example, the following arrays shows 8 cities and their respective populations:[3, 6, 0, 4, 3, 2, 7, 1]Some cities have a population of 0 due to a pandemic zombie disease that is wiping away the human lives. After each day, any city that is adjacent to a zombie-ridden city will lose half of its population.Write a program to loop though each city population and make it lose half of its population if it is adjacent (right or left) to a city with zero people until all cities have no humans left.

package Arrays;

public class Project {
public static void main(String[] args){
    int i = 0;
    boolean hi = false;
    boolean hi1 = false;
    boolean hi2 = false;
    boolean hi3 = false;
    boolean hi4 = false;
    boolean hi5 = false;
    boolean hi6 = false;
    boolean hi7 = false;
    int[] a = {3, 6, 0, 4, 3, 2, 7, 1};
    if(a[0]==0) {
        hi=true;
    }
    if(a[1]==0) {
        hi1=true;
    }
    if(a[2]==0) {
        hi2=true;
    }
    if(a[3]==0) {
        hi3=true;
    }
    if(a[4]==0) {
        hi4=true;
    }
    if(a[5]==0) {
        hi5=true;
    }
    if(a[6]==0) {
        hi6=true;
    }
    if(a[7]==0) {
        hi7=true;
    }
    int z=1;
    while(hi!=false || hi1!=false || hi2!=false ||  hi3!=false || hi4!=false || hi5!=false || hi6!=false || hi7!=false) {
    if(hi=true){
        a[1]=a[1]/2;
    }
    if(hi1=true){
        a[0]=a[0]/2;
        a[2]=a[2]/2;
    }
    if(hi2=true){
        a[1]=a[1]/2;
        a[3]=a[3]/2;
    }
    if(hi3=true){
        a[2]=a[2]/2;
        a[4]=a[4]/2;
    }
    if(hi4=true){
        a[3]=a[3]/2;
        a[5]=a[5]/2;
    }
    if(hi5=true){
        a[4]=a[4]/2;
        a[6]=a[6]/2;
    }
    if(hi6=true){
        a[5]=a[5]/2;
        a[7]=a[7]/2;
    }
    if(hi7=true){
        a[6]=a[6]/2;
    }
    System.out.println("Day "+i+": ["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+"] ");
    i++;
    }
        }
}

I think it is pretty simple. Just go through the array and check previous and next value.

public static void calc(int[] arr) {
    for(int i = 1; i < arr.length; i++)
        if(arr[i] > 0 && arr[i - 1] == 0)
            arr[i] /= -2;

    for(int i = arr.length - 2; i >= 0; i--)
        if(arr[i] < 0)
            arr[i] = -arr[i];
        else if(arr[i] > 0 && arr[i + 1] == 0)
            arr[i] /= 2;
}

Dividing by Zero, So they get 4 each: 12/3 = 4 After dividing, can we multiply to get back again? multiply by zero. But multiplying by 0 gives 0, For example, we know that zero times any number is zero: Example: 0×1 = 0, 0×2 = 0, etc. So that should also be​  The inverse of a number is defined to be the number which, when multiplied by the original number, equals one; e.g. x*x-1 = 1. Now, in the algebraic structures we're all familiar with, any number


I am also new to Java, but here is my attempt.

import java.util.Arrays;

public class Project {

public static void main(String[] args) {

    int[] a = {3, 6, 0, 4, 3, 2, 7, 1};
    zombieApocalypse(a);

}


public static void zombieApocalypse(int[] array) {

    boolean keepGoing = true;

    int j = 1;
    while (keepGoing) {

        int[] arrayCopy = array;

        //first element
        if (array[0] == 0) {
            arrayCopy[1] = array[1] / 2;
        }

        //element in the middle
        for (int i = 1; i < array.length - 1; i++) {

            if (array[i] == 0) {
                arrayCopy[i - 1] = array[i - 1] / 2;
                arrayCopy[i + 1] = array[i + 1] / 2;
            }

        }

        //last element
        if (array[array.length - 1] == 0) {
            arrayCopy[array.length - 1] = array[array.length - 1] / 2;
        }

        System.out.println("Day " + j);
        //copies clone back to original array
        array = arrayCopy;
        System.out.println(Arrays.toString(array));

        j++;

        int counter = 0;
        //for each element checking if every city is zero
        for (int element : array) {
            counter = counter + element;
        }

        //if each element value in every city is zero, we stop
        if (counter == 0) {
            keepGoing = false;
        }
    }
}
}

Division by zero, https://www.khanacademy.org › › Algebra foundations › Division by zero 18 - 6 = 12. 12 - 6 = 6. 6 - 6 = 0. When you subtract zero, the dividend doesn't change, so no. matter how many times you take zero away, you will never reach. zero: 18 - 0 = 18. 18 - 0 = 18. 18


This is what you were going for.

import java.util.Arrays;

public class Project {

public static void main(String[] args) {

    int i = 0;

    boolean hi = false;
    boolean hi1 = false;
    boolean hi2 = false;
    boolean hi3 = false;
    boolean hi4 = false;
    boolean hi5 = false;
    boolean hi6 = false;
    boolean hi7 = false;

    int[] a = {3, 6, 0, 4, 3, 2, 7, 1};


    //the line of code below this comment is never used ever, what is it for?
    int z = 1;

    while ((((!hi || !hi1) || (!hi2 || !hi3)) || (!hi4 || !hi5)) || (!hi6 || !hi7)){

        if (hi) {
            a[1] = a[1] / 2;
        }
        if (hi1) {
            a[0] = a[0] / 2;
            a[2] = a[2] / 2;
        }
        if (hi2) {
            a[1] = a[1] / 2;
            a[3] = a[3] / 2;
        }
        if (hi3) {
            a[2] = a[2] / 2;
            a[4] = a[4] / 2;
        }
        if (hi4) {
            a[3] = a[3] / 2;
            a[5] = a[5] / 2;
        }
        if (hi5) {
            a[4] = a[4] / 2;
            a[6] = a[6] / 2;
        }
        if (hi6) {
            a[5] = a[5] / 2;
            a[7] = a[7] / 2;
        }
        if (hi7) {
            a[6] = a[6] / 2;
        }

        System.out.println("Day " + i + Arrays.toString(a));
        i++;

        /*if you want to update the boolean values after they are changed, then you have to include it within the block of code
        that is changing it. (if they are outside of this block of code, how will they ever update?)
        */

        if (a[0] == 0) {
            hi = true;
        }
        if (a[1] == 0) {
            hi1 = true;
        }
        if (a[2] == 0) {
            hi2 = true;
        }
        if (a[3] == 0) {
            hi3 = true;
        }
        if (a[4] == 0) {
            hi4 = true;
        }
        if (a[5] == 0) {
            hi5 = true;
        }
        if (a[6] == 0) {
            hi6 = true;
        }
        if (a[7] == 0) {
            hi7 = true;
        }

    }

}
}

Why dividing by zero is undefined (video), I think it is pretty simple. Just go through the array and check previous and next value. public static void calc(int[] arr) { for(int i = 1; i < arr.length; i++) if(arr[i] > 0  In Part 1 of our Excel IF function tutorial, we started to learn the nuts and bolts of the Excel IF function.As you remember, we discussed a few IF formulas for numbers, dates and text values as well as how to write an IF statement for blank and non-blank cells.


How do i make it so every number that is next to a zero divides by two?, They also need zero to say that there is not any of some type of thing. 1+8 can be found by thinking of it as 8+1 and then just recalling the next whole number after 8. For example, is the number you get when you divide 2 into 3 equal parts. Adjusting Your Paycheck Tax Withholding To Keep More Money In Your Bank Account. By Peter Anderson 30 Comments-The content of this website often contains affiliate links and I may be compensated if you buy through those links (at no cost to you!). Learn more about how we make money. Last edited March 4, 2020.


3 NUMBER: WHAT IS THERE TO KNOW?, So, the answer, after putting the decimal, will be 2.4. The last zeros in the decimals may be removed. Division 1 . Multiply the divisor by the power of 10 to make it a whole number. 2. Multiply the number being divided by the same power of 10. by any power of 10, move the decimal place to the left, one place for each zero  Then zero is certainly divisible by zero as every integer follows that definition. If your notion of divisibility actually means to be able to divide those two and get some definite value then it is not divisible But according to what I think it is.


The Pearson CSAT Manual 2011, It is easy to see that, if we divide any number by three, only three possibilities exists for the To design the FA, we therefore need to group the digits (0, 1, 2, 3, denotes group C. So after reading the first digit the FA will make a transition to one of q1 and if the next digit is say 4, then the FA will make transition to state q2. WEEKDAY (serial_number, [return_type]) function returns the day of the week corresponding to a date, as a number from 1 (Sunday) to 7 (Saturday). Serial_number can be a date, a reference to a cell containing a date, or a date returned by some other Excel function.