Calculating Area of Triangle using Class and Objects

 

class Triangle{
    int height;
int base;

void assignValue(int h, int b){
height =h;
base = b;
}

void calculateArea(){
System.out.println("Area of Triangle is = "+height*base*1/2);
}
}

public class TestTriangle{
public static void main(String args[]){
Triangle t1 = new Triangle();
Triangle t2 = new Triangle();
Triangle t3 = new Triangle();

t1.assignValue(4,5);
t2.assignValue(24,15);
t3.assignValue(12,25);

t1.calculateArea();
t2.calculateArea();
t3.calculateArea();
}
}

Google Script for Data Entry Form in Google Spreadsheet

// function to validate the entry made by user in user form function validateEntry (){ // declare a variable and referernece of active goog...