Skip to content

Instantly share code, notes, and snippets.

import java.util.*;
public class Library {
String adress;
ArrayList<Book> list;
public Library(String lib){
this.adress=lib;
this.list= new ArrayList<Book>();
}
@gilrg18
gilrg18 / Book
Created May 4, 2016 03:31
WSQ11
public class Book {
String title;
boolean borrowed; //default boolean value is false
// Creates a new Book
public Book(String bookTitle) {
this.title=bookTitle;
}
// Marks the book as rented
public void borrowed() {
this.borrowed=true;
public class GravityCalculator {
double gravity;
double initialVelocity;
double fallingTime= 10.0;
double initialPosition;
public GravityCalculator(double a, double t, double vi, double xi){ //Default Constructor
this.gravity=a;
this.fallingTime=t;
this.initialVelocity=vi;
package poo;
//Gilberto Rogel García WSQ08 YoSoy196
import javax.swing.*;
public class YoSoy196 {
int low,
up,
pal=0,
non=0,
lych=0;
public YoSoy196(int x, int y){
@gilrg18
gilrg18 / Babylonian Method
Created February 4, 2016 18:41
WSQ07 TC201 Babylonian Method
//Gilberto Rogel García A01630171
import javax.swing.*;
public class Babylonian {
public double x,
y=0;
public double bm(double a){
this.x=a;
while (this.x!= this.y){
this.y=this.x;
this.x=(a/this.x + this.x)/2;
@gilrg18
gilrg18 / Greatest common divisor
Last active February 19, 2016 02:17
WSQ06 TC201 GCD
//Greatest Common Divisor by Gilberto Rogel García A01630171
public class GCD {
public int num;
public GCD(int num){
this.num = num;
}
public int greatestCD(int x){
if (this.num == x){
def car():
x=open("93cars.dat.txt","r")
mpgc=0
mpgh=0
mp=0
cars=0
f=1
for line in x:
if f%2==1:
mpgc=mpgc+float(line[52:54])
@gilrg18
gilrg18 / Question1
Last active August 29, 2015 14:20
Quiz11
#Gilberto Rogel García Quiz11 Question1
import statistics
def readNumbersFromFile():
fint=[]
f=open('random_numbers.txt','r') #'r' = read 'w'= readwrite
lines=0
total=0
for line in f:
total+= int(line)
@gilrg18
gilrg18 / Quesiton 2
Created April 23, 2015 16:15
Quiz#10
#Gilberto Rogel García a01630171
def dotProduct (v1,v2):
if (len(v1)) == len(v2):
dotpro=0
for y in range (0,len(v1)):
x= v1[y]*v2[y]
dotpro+=x
else:
print ("Not same size vectors")
return -1
#Distance between two points Gilberto Rogel García
#Gilberto Rogel García
import math
def distancia(x1,y1,x2,y2):
a=x2-x1
b=y2-y1
dis=math.sqrt((a*a)+(b*b))
return (dis)