This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Library { | |
String adress; | |
ArrayList<Book> list; | |
public Library(String lib){ | |
this.adress=lib; | |
this.list= new ArrayList<Book>(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) | |
NewerOlder