Tags » Arrays

Wednesday, 12th August 2020 - Numeracy

Doubling

I am learning to multiply by 2 or double.

I know I can do it when I can make it double using 1 and 2 digit numbers. 260 more words

Numeracy

Monday, 10th August 2020 - Numeracy

Groups

Multiplying by 10

I am learning to show multiplication as groups.

I know I can do it when I can create arrays to help me solve problems. 146 more words

Numeracy

Lesson 19: Arrays

So far, we have gone over several different types of data we encounter in Java. Some of these data types include: chars, Strings, ints, and doubles. 533 more words

Introduction To Java

Wednesday, 29th July 2020 - Numeracy

Arrays Around Us

I am learning to identify arrays around me in everyday life.

I know I can do it when I can identify arrays in the world around me. 135 more words

Numeracy

Odds and Evens - Arrays

import java.util.Arrays;
import java.util.Scanner;

/*AniBlogger12
 * Odds and Evens- Arrays
 */
public class oddsAndEvens {

	public static void main(String[] args) {
		// get keyboard
		Scanner kb = new Scanner(System.in);
		// initialize array, specify number of integers you want typed
		int[] array = new int;
		// prompt user
		System.out.println("Please enter a list");
		// for 10 numbers entered
		for (int i = 0; i < 10; i++) {
			// put it into an array
			array[i] = kb.nextInt();
		}
		// loop through the numbers one by one
		for (int i = 0; i < array.length; i++) {
			//if number is divisible by 2
			if (array[i] % 2 == 0) {
				//it is even and is replaced with 0
				array[i] = 0;
				//or else:
			} else {
				//it is odd and is replaced with 1
				array[i] = 1;
			}
		}
		//print out the new array
		System.out.print("The new array is " + Arrays.toString(array) + "\n");
	}

}

Upcasting an Array of Object to an Array of Any

I wanted a generic method that would accept an array of a custom object whose type can be ObjectA, ObjectB, and so on. I tried declaring the method like this: 285 more words

PeopleCode

Prime Numbers Factorial

Write a program to check whether the given number is prime number or not, if it is prime number display the factorial.

import java.util.*;
public class primeFactorial
{    
    int i,m,flag,n;  
    primeFactorial()
    {
        n=0;
        m=0;
        flag=0;
    }
    public  void input()
    {    
        Scanner sc = new Scanner (System.in);
        System.out.println("Enter the number:");
        n=sc.nextInt();
    }
    public void calculate()
    {
       input();        // input()method invocation
        m=n/2;      
        if(n==0||n==1)
        {  
            System.out.println(n+" is not prime number");      
           
        }
        else
        {  
            for(i=2;i<=m;i++)
            {      
                if(n%i==0)
                {          
                    flag=1;      //status variable, if any divisor found, flag=1
                    break;      
                }      
            } // end of for loop
            if(flag==0) 
            { 
                System.out.println(n+" is prime number"); 
                fact(n);
                
            }
            else    
            {
                System.out.println(n+" is not prime number");
            }
        }//end of outer else  
    }
   public void fact(int num1)
   {
       int n2=num1,fact=1;
       for(int j=1;j<=n2;j++)
       fact=fact *j;
       System.out.println("Factorial " +   fact);
    }
    
 public static void main(String args[])
 {    
     primeFactorial pN=new primeFactorial();
     pN.calculate();   // calculate() method call
  
    }
}   … 15 more words
Education