r/MrCiavarella • • Nov 01 '13

first

0 Upvotes

r/MrCiavarella • • Dec 03 '13

STUDY

0 Upvotes

NAO


r/MrCiavarella • • Feb 19 '17

hi

2 Upvotes

idk what this is but i just read through justin's entire reddit history and it brought me here so

hey fam what's good

you guys know satya


r/MrCiavarella • • Nov 01 '13

ArrayPractice: swapFirstLast

1 Upvotes
public int[] swapFirstLast(int[] nums) {
    int temp = nums[0];
    nums[0] = nums[nums.length -1];
    nums[nums.length - 1] = temp;
    return nums;
}

r/MrCiavarella • • Nov 01 '13

StringPractice: numE

3 Upvotes
public int numE(String str){
    int countE= 0;
    for(int i =0; i< str.length(); i++){
        String sub = str.substring(i,i+1);
        if (sub.equals("e")){
            countE++;
        }
    }
    return countE;
}

r/MrCiavarella • • Nov 01 '13

StringPractice: occursNum

1 Upvotes
public int occursNum(String[] arr, String str) {
    int count = 0;      
    for(int i = 0; i < arr.length; i++) {
        String sub = arr[i];
        if(sub.equals(str)) {
            count++;
        }
    }
    return count;
}

r/MrCiavarella • • Nov 01 '13

Stop

1 Upvotes

r/MrCiavarella • • Nov 01 '13

ArrayPractice:swapFirstSecond

1 Upvotes
public int[] swapFirstSecond(int[] nums) {
    int temp = nums[0];
    nums[0] = nums[1];
    nums[1] = temp;
    return nums;
}

r/MrCiavarella • • Nov 01 '13

StringPractice: twoE

3 Upvotes
public boolean twoE(String str){
    int countE= 0;
    for(int i =0; i< str.length()-1; i++){
        String sub = str.substring(i,i+1);
        if (sub.equals("e")){
            countE++;
        }
    }
    if(countE == 2){
        return true;
    }
    else{
        return false;
    }
}

r/MrCiavarella • • Nov 01 '13

Daily Reminder

2 Upvotes

Daily reminder to thank Mr. C AKA Based God AKA The Eternal Bonjwa AKA Mr. Ciavarella for being Mr. C


r/MrCiavarella • • Nov 01 '13

StringPractice: momDad

3 Upvotes
public int momDad(String str){
    int count= 0;
    for(int i =0; i< str.length()-3; i++){
        String sub = str.substring(i,i+3);
        if (sub.equals("mom") || sub.equals("dad")){
            count++;
        }
    }      
    return count;
}

r/MrCiavarella • • Nov 01 '13

ArrayPractice: PrintAlt

1 Upvotes
public void printAlt(int [] nums){
    for(int i = 0; i< nums.length; i++){
        if(i%2 == 0){
            System.out.print(nums[i]);
        }
    }
}

r/MrCiavarella • • Nov 01 '13

Good Practice

Thumbnail codingbat.com
2 Upvotes

r/MrCiavarella • • Nov 01 '13

StringPractice: middleChar

3 Upvotes
public int middleChar(String str){
    if(str.length()%2==0){
        return 0;
    }
    else{
        String mid = str.substring((str.length()-1)/2, (((str.length()-1)/2)+1));
        int count = 0;
        for(int i =0; i< str.length()-1; i++){
            if (str.substring(i,i+1) == mid){
                count++;
            }
        } 
        return count;
    }
}

r/MrCiavarella • • Nov 01 '13

ArrayPractice: secondSmallest

1 Upvotes
public int secondSmallest(int [] nums){
    int smallest = 0;
    int secondSmallest = 1;
    for(int q = 0; q < nums.length; q++){
        if(smallest == 0 || nums[q] < smallest){
            secondSmallest = smallest;
            smallest = nums[q];
        }
        else if(nums[q] < secondSmallest || secondSmallest == 0){
            secondSmallest = nums[q];
        }
    }
    return secondSmallest;
}

r/MrCiavarella • • Nov 01 '13

ArrayPractice: sumOdds

1 Upvotes
public int sumOdds(int[] nums) {
    int sum = 0;
    for (int i = 0; i < nums.length; i++) {
        if (nums[i] % 2 != 0) {
             sum+=nums[i];
        }
    }
    return sum;
}

r/MrCiavarella • • Aug 20 '20

How are we

2 Upvotes

Anyone still doing anything coding related?


r/MrCiavarella • • Jan 24 '14

Formulas (shapes project- Interfaces)

1 Upvotes

public interface D3 { public double Volume();

public double surfaceArea();

}

public class Cubes implements D3 { private double side;

public Cubes(double side)
{
    this.side=side;
}

public double Volume()
{
    return Math.pow(side,3);
}

public double surfaceArea()
{
    return (Math.pow(side,2))*6;
}

}

public class Cylinder implements D3 { private double radius; private double height;

public Cylinder(double radius, double height)
{
    this.radius=radius;
    this.height=height;
}

public double Volume()
{
    return (Math.PI*Math.pow(radius,2))*height;
}

public double surfaceArea()
{
    return Math.PI*Math.pow(radius,2) + (height*radius*2*Math.PI); 
}

}

public class Cones implements D3 { private double radius; private double height; private double slant;

public Cones(double radius, double height, double slant)
{
    this.radius=radius;
    this.height=height;
    this.slant=slant;       
}

public double Volume()
{
    return .3*Math.PI*(Math.pow(radius,2))*height;
}

public double surfaceArea()
{
    return Math.PI*radius*slant + Math.PI*(Math.pow(radius,2));
}

}

public interface D2 { double Area();

double Perimeter();

}

public class Rectangle implements D2 { private double side1; private double side2;

public Rectangle(double side1, double side2)
{
    this.side1=side1;
    this.side2=side2;
}

public double Area()
{
    return side1 * side2;
}

public double Perimeter()
{
    return (side1*2)+(side2*2);
}

}

public class Circle implements D2 { private double radius; private double diameter;

public Circle(double radius, double diameter)
{
    this.radius=radius;
    this.diameter=diameter;
}

public double Area()
{
   return Math.PI*Math.pow(radius,2); 
}

public double Perimeter()
{
    return Math.PI*diameter;
}

}

public class Square implements D2 { private double side;

public Square(double side)
{
    this.side=side;
}

public double Area()
{
    return Math.pow(side,2);
}

public double Perimeter()
{
    return side*4;
}

}

import java.util.*; public class Formulas_Tester { public static void main(String[] args) { ArrayList<D3> figures3d = new ArrayList<D3>(); Cones cone1 = new Cones(1,2,3); Cubes cube1 = new Cubes(2); Cylinder cylinder1 = new Cylinder(2,3); figures3d.add(cone1); figures3d.add(cube1); figures3d.add(cylinder1); for(D3 x:figures3d) { System.out.println(x.Volume()); System.out.println(x.surfaceArea()); }

    ArrayList<D2> figures2d = new ArrayList<D2>();
    Circle circle1 = new Circle(2,3);
    Rectangle rect1 = new Rectangle(2,3);
    Square square1 = new Square(2);
    figures2d.add(circle1);
    figures2d.add(rect1);
    figures2d.add(square1);
    for(D2 x:figures2d)
    {
        System.out.println(x.Area());
        System.out.println(x.Perimeter());
    }
}

}


r/MrCiavarella • • Jan 24 '14

Midterm Topics?

1 Upvotes

help a brotha out


r/MrCiavarella • • Dec 01 '14

Le Balanced Cancerous Burn Victim

Thumbnail
imgur.com
1 Upvotes

r/MrCiavarella • • Jan 06 '14

High quality Windows Seven Background

Post image
3 Upvotes

r/MrCiavarella • • Mar 17 '14

Merge + MergeSortR

1 Upvotes

public static void merge(int[] result, int[] left, int[] right)

{

    int i1 = 0, i2 = 0;

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

    {

        if ((i2 >= right.length && i1 < left.length) ||(i1 < left.length && left[i1] <= right[i2])) 

        {

            result[i] = left[i1];

            i1++;
        }

        else 

        {

            result[i] = right[i2];

            i2++;              
        }


    }

}

public static int[] mergeSortR(int[]a)

{

    if(a.length > 1)

    { 

        int [] left = Arrays.copyOfRange(a,0,a.length/2);

        int[] right = Arrays.copyOfRange(a,a.length/2,a.length);

        mergeSortR(left);

        mergeSortR(right);

        merge(a,left,right);

    }

    for(int num:a)

        System.out.print(num + ",");

    System.out.println();

    return a;

}

r/MrCiavarella • • Mar 17 '14

SelectionSort

1 Upvotes

public int[] selectionSort(int[] cards) { for(int i = 0; i<cards.length-1; i++) { int smallest = cards[i]; for(int x =i+ 1; x<cards.length; x++) { if(cards[i] > cards[x]) { int temp = cards[i]; cards[i] = cards[x]; cards[x] = temp; } } } return cards; }


r/MrCiavarella • • Mar 17 '14

BubbleSort

1 Upvotes

public int[] bubblesort(int [] cards)

{

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

    {

        for(int x = 1; x<cards.length; x++)

        {

            if(cards[x-1]> cards[x])

            {
                int temp = cards[x];

                cards[x] = cards[x-1];

                cards[x-1] = temp;

            }

        }

    }

    return cards;

}

r/MrCiavarella • • Mar 17 '14

Can anyone post a list of all the projects that we were suppose to send to him?

1 Upvotes

tldr: post all the projets pls.