diff --git a/calculadora.html b/calculadora.html new file mode 100644 index 0000000..bc24304 --- /dev/null +++ b/calculadora.html @@ -0,0 +1,31 @@ + + + + + + Page Title + + + + + +

+ + + + + + + + + + + + + + +
7 8 9 +
4 5 6 -
1 2 3 *
00 0 . =
+ + + + \ No newline at end of file diff --git a/join.sql b/join.sql new file mode 100644 index 0000000..3c79800 --- /dev/null +++ b/join.sql @@ -0,0 +1,60 @@ +select distinct c.customer_id,c.first_name from customer as c right join rental as r on c.customer_id = r.customer_id; + +select c.customer_id,c.first_name,f.title +from customer as c right join rental as r on c.customer_id = r.customer_id +right join payment as p on r.rental_id=p.rental_id +left join inventory as i on r.inventory_id=i.inventory_id +left join film as f on i.film_id=f.film_id +where p.payment_date<'2007-02-15'; + +select count(c.category_id) cantidad,c.name +from rental as r +left join inventory as i on r.inventory_id=i.inventory_id +left join film as f on i.film_id=f.film_id +left join film_category as fc on f.film_id=fc.film_id +left join category as c on c.category_id=fc.category_id +group by c.category_id +order by cantidad desc limit 5 +; + +select count(c.category_id) cantidad,c.name,cu.customer_id +from rental as r +left join customer as cu on r.customer_id = cu.customer_id +left join inventory as i on r.inventory_id=i.inventory_id +left join film as f on i.film_id=f.film_id +left join film_category as fc on f.film_id=fc.film_id +left join category as c on c.category_id=fc.category_id +group by (c.category_id,cu.customer_id) +order by cu.customer_id,cantidad desc +; + +select cantidad, nom from (select count(l.name) cantidad, l.name nom +from rental as r +left join inventory as i on r.inventory_id=i.inventory_id +left join film as f on i.film_id=f.film_id +left join language as l on f.language_id=l.language_id +group by l.language_id ) as sq order by cantidad desc limit 1 +; + +select count(r.rental_id) cantidad, s.staff_id, s.first_name +from rental as r +left join payment as p on r.rental_id=p.rental_id +right join staff as s on p.staff_id=s.staff_id +group by s.staff_id +; + +select count(a.actor_id) cantidad,a.first_name +from rental as r +left join inventory as i on r.inventory_id=i.inventory_id +left join film as f on i.film_id=f.film_id +right join film_actor as fa on f.film_id=fa.film_id +right join actor as a on a.actor_id=fa.actor_id +group by a.actor_id +order by cantidad desc limit 1 +; + +select count(c.customer_id) cantidad,c.first_name +from rental as r +left join customer as c on c.customer_id=r.customer_id +group by c.customer_id order by cantidad desc limit 1 +; \ No newline at end of file diff --git a/main.js b/main.js new file mode 100644 index 0000000..146ee77 --- /dev/null +++ b/main.js @@ -0,0 +1,124 @@ +const teclas = document.querySelectorAll('.tecla'); +var screen = document.getElementById("screen"); +var screenAnterior = document.getElementById("screen-anterior"); +var entrada_anterior; +var dot_posible = true; +var escribir = function(event) { + let contenido = event.target.innerHTML; + switch (getTipo(contenido)) { + case "num": + switch (getTipo(entrada_anterior)) { + case "num": + screen.value = Number(screen.value + contenido) + break; + case "op": + screen.value = contenido + break; + case "dot": + screen.value = Number(screen.value + contenido) + break; + case "eq": + screen.value = contenido + screenAnterior.innerHTML = "" + break; + + default: + break; + } + + + break; + + case "op": case "eq": + let ls = screenAnterior.innerHTML.length-1; + if(screen.value.length==0 && screenAnterior.innerHTML.length==0) return; + switch (getTipo(entrada_anterior)) { + case "num": case "dot": + if(esOperador(screenAnterior.innerHTML[ls])){ + let a = screenAnterior.innerHTML.substring(0,ls); + let b = screen.value + screen.value = operar(Number(a),Number(b),screenAnterior.innerHTML[ls]) + if (getTipo(contenido)=="eq") { + screenAnterior.innerHTML += b + contenido; + } else { + screenAnterior.innerHTML = screen.value + contenido; + } + } + else{ + screenAnterior.innerHTML = Number(screen.value) + contenido; + } + + break; + case "op": + screenAnterior.innerHTML = screenAnterior.innerHTML.substring(0,ls) + contenido; + break; + + case "eq": + screenAnterior.innerHTML = Number(screen.value) + contenido; + default: + break; + } + dot_posible = true; + + break; + + case "dot": + if(dot_posible){ + switch (getTipo(entrada_anterior)) { + case "num": + dot_posible = false; + screen.value = screen.value + contenido; + break; + + default: + break; + } + } + + break; + + default: + break; + } + + entrada_anterior = contenido; + +}; +function esNumero(valor){ + return !isNaN(Number(valor)) +} + +function esOperador(valor){ + switch (valor) { + case "+": case "-": case "/": case "*": + return true; + default: + return false; + } +} + +function getTipo(valor){ + if(esNumero(valor)) return "num"; + if(esOperador(valor)) return "op"; + if(valor=="=") return "eq"; + if(valor==".") return "dot"; +} + +function operar(a,b,op){ + switch (op) { + case "+": + + return a + b; + case "-": + + return a - b; + case "/": + + return a / b; + case "*": + + return a * b; + } +} + +teclas.forEach(el => el.addEventListener('click', escribir)); \ No newline at end of file