martes, 14 de julio de 2015
JAVASCRIPT: Cambia el Color de Fondo de la Web Automáticamente
<script>
///////////////////////////////////////////////////////////////////////////
// LA CONFIGURACION INICIA AQUI
///////////////////////////////////////////////////////////////////////////
// Selecciona los colores (valores hexadecimales requeridos)
var colors=new Array("#FFFF00","#00FFFF","#5fc700","#854b00","#76e07c","#FFAC00",
"#FFFF66","#ff0000","#FFFFFF","#850044","#B56AFF","#56B1FF")
// Poner pausa entre colores (segundos)
var pausebetweencolors=2
// Que tipo de degradado aplicar.
// Set "none" or "horizontal" or "vertical"
var gradient_effect="horizontal"
// Set speed (higher=slower)
var speed=20
//Repeticiones
// Agregar valor entre 1 y 9999999
var i_loopmax=1000
///////////////////////////////////////////////////////////////////////////
// LA CONFIGURACION TERMINA AQUI
///////////////////////////////////////////////////////////////////////////
// NO MODIFICAR NADA DESDE AQUI
var pausesteps=40
var hexc = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F')
var redcol_1
var redcol_2
var redcol_1_b
var redcol_2_b
var greencol_1
var greencol_2
var greencol_1_b
var greencol_2_b
var bluecol_1
var bluecol_2
var bluecol_1_b
var bluecol_2_b
var rgbredfrom
var rgbgreenfrom
var rgbbluefrom
var rgbredto
var rgbgreento
var rgbblueto
var rgbrednow
var rgbgreennow
var rgbbluenow
var rgbredfrom_b
var rgbgreenfrom_b
var rgbbluefrom_b
var rgbredto_b
var rgbgreento_b
var rgbblueto_b
var rgbrednow_b
var rgbgreennow_b
var rgbbluenow_b
var colorhexafrom
var colorhexato
var i_step=1
var i_loop=0
var i_colorsA=0
var i_colorsB=1
var i_colorsC=1
var i_colorsD=2
pausebetweencolors*=1000
var browserinfos=navigator.userAgent
var ie4=document.all&&!document.getElementById
var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/)
var ns4=document.layers
var ns6=document.getElementById&&!document.all
var opera=browserinfos.match(/Opera/)
var browserok=ie4||ie5||ns4||ns6||opera
function translateintorgb() {
var hexa=colors[i_colorsA]
var hexared=hexa.substring(1,3)
var hexagreen=hexa.substring(3,5)
var hexablue=hexa.substring(5,7)
rgbredfrom=parseInt("0x"+hexared)
rgbgreenfrom=parseInt("0x"+hexagreen)
rgbbluefrom=parseInt("0x"+hexablue)
rgbrednow=rgbredfrom
rgbgreennow=rgbgreenfrom
rgbbluenow=rgbbluefrom
var hexa=colors[i_colorsB]
var hexared=hexa.substring(1,3)
var hexagreen=hexa.substring(3,5)
var hexablue=hexa.substring(5,7)
rgbredto=parseInt("0x"+hexared)
rgbgreento=parseInt("0x"+hexagreen)
rgbblueto=parseInt("0x"+hexablue)
var hexa=colors[i_colorsC]
var hexared=hexa.substring(1,3)
var hexagreen=hexa.substring(3,5)
var hexablue=hexa.substring(5,7)
rgbredfrom_b=parseInt("0x"+hexared)
rgbgreenfrom_b=parseInt("0x"+hexagreen)
rgbbluefrom_b=parseInt("0x"+hexablue)
rgbrednow_b=rgbredfrom_b
rgbgreennow_b=rgbgreenfrom_b
rgbbluenow_b=rgbbluefrom_b
var hexa=colors[i_colorsD]
var hexared=hexa.substring(1,3)
var hexagreen=hexa.substring(3,5)
var hexablue=hexa.substring(5,7)
rgbredto_b=parseInt("0x"+hexared)
rgbgreento_b=parseInt("0x"+hexagreen)
rgbblueto_b=parseInt("0x"+hexablue)
i_colorsA++
i_colorsB++
i_colorsC++
i_colorsD++
if (i_colorsA>=colors.length) {i_colorsA=0}
if (i_colorsB>=colors.length) {i_colorsB=0}
if (i_colorsC>=colors.length) {i_colorsC=0}
if (i_colorsD>=colors.length) {i_colorsD=0}
changefromto()
}
function changefromto() {
rgbrednow=rgbrednow-((rgbredfrom-rgbredto)/speed)
rgbgreennow=rgbgreennow-((rgbgreenfrom-rgbgreento)/speed)
rgbbluenow=rgbbluenow-((rgbbluefrom-rgbblueto)/speed)
rgbrednow_b=rgbrednow_b-((rgbredfrom_b-rgbredto_b)/speed)
rgbgreennow_b=rgbgreennow_b-((rgbgreenfrom_b-rgbgreento_b)/speed)
rgbbluenow_b=rgbbluenow_b-((rgbbluefrom_b-rgbblueto_b)/speed)
if (rgbrednow>255) {rgbrednow=255}
if (rgbrednow<0) {rgbrednow=0}
if (rgbgreennow>255) {rgbgreennow=255}
if (rgbgreennow<0) {rgbgreennow=0}
if (rgbbluenow>255) {rgbbluenow=255}
if (rgbbluenow<0) {rgbbluenow=0}
if (rgbrednow_b>255) {rgbrednow_b=255}
if (rgbrednow_b<0) {rgbrednow_b=0}
if (rgbgreennow_b>255) {rgbgreennow_b=255}
if (rgbgreennow_b<0) {rgbgreennow_b=0}
if (rgbbluenow_b>255) {rgbbluenow_b=255}
if (rgbbluenow_b<0) {rgbbluenow_b=0}
if (i_step<=speed) {
redcol_1 = hexc[Math.floor(rgbrednow/16)];
redcol_2 = hexc[Math.floor(rgbrednow)%16];
greencol_1 = hexc[Math.floor(rgbgreennow/16)];
greencol_2 = hexc[Math.floor(rgbgreennow)%16];
bluecol_1 = hexc[Math.floor(rgbbluenow/16)];
bluecol_2 = hexc[Math.floor(rgbbluenow)%16];
redcol_1_b = hexc[Math.floor(rgbrednow_b/16)];
redcol_2_b = hexc[Math.floor(rgbrednow_b)%16];
greencol_1_b = hexc[Math.floor(rgbgreennow_b/16)];
greencol_2_b = hexc[Math.floor(rgbgreennow_b)%16];
bluecol_1_b = hexc[Math.floor(rgbbluenow_b/16)];
bluecol_2_b = hexc[Math.floor(rgbbluenow_b)%16];
var backcolor="#"+redcol_1+redcol_2+greencol_1+greencol_2+bluecol_1
+bluecol_2
var backcolor_b="#"+redcol_1_b+redcol_2_b+greencol_1_b+greencol_2_b
+bluecol_1_b+bluecol_2_b
if (ie5 && gradient_effect!="none") {
if (gradient_effect=="horizontal") {var gr_effect=1}
if (gradient_effect=="vertical") {var gr_effect=0}
document.body.style.filter=
"progid:DXImageTransform.Microsoft.Gradient(startColorstr="+backcolor+", endColorstr="+backcolor_b+", GradientType="+gr_effect+")"
}
else {
document.bgColor=backcolor
}
i_step++
var timer=setTimeout("changefromto()",pausesteps);
}
else {
clearTimeout(timer)
i_step=1
i_loop++
if (i_loop<i_loopmax) {var timer=setTimeout("translateintorgb()",pausebetweencolors);}
}
}
if (bowserok) {
window.onload=translateintorgb
}
</script>
JAVASCRIPT: Crear una Agenda de Direcciones con COOKIES
<SCRIPT LANGUAGE="JavaScript">
var arrRecords = new Array();
var arrCookie = new Array();
var recCount = 0;
var strRecord="";
expireDate = new Date;
expireDate.setDate(expireDate.getDate()+365);
function cookieVal(cookieName) {
thisCookie = document.cookie.split("; ")
for (i = 0; i < thisCookie.length; i++) {
if (cookieName == thisCookie[i].split("=")[0]) {
return thisCookie[i].split("=")[1];
}
}
return 0;
}
function loadCookie() {
if(document.cookie != "") {
if(cookieVal("Records") != ""){
arrRecords = cookieVal("Records").split(",");
}
currentRecord();
}
}
function setRec() {
strRecord = "";
for(i = 0; i < document.frm1.elements.length; i++) {
strRecord = strRecord + document.frm1.elements[i].value + ":";
}
arrRecords[recCount] = strRecord;
document.frm2.add.value = " NEW ";
document.cookie = "Records="+arrRecords+";expires=" + expireDate.toGMTString();
}
function newRec() {
switch (document.frm2.add.value) {
case " NEW " :
varTemp = recCount;
for(i = 0; i < document.frm1.elements.length; i++) {
document.frm1.elements[i].value = ""
}
recCount = arrRecords.length;
document.frm2.add.value = "CANCEL";
break;
case "CANCEL" :
recCount = varTemp;
document.frm2.add.value = " NEW ";
currentRecord();
break;
}
}
function countRecords() {
document.frm2.actual.value = "Record " + (recCount+1)+"; "+arrRecords.length+" saved records";
}
function delRec() {
arrRecords.splice(recCount,1);
navigate("previous");
setRec();
}
function currentRecord() {
if (arrRecords.length != "") {
strRecord = arrRecords[recCount];
currRecord = strRecord.split(":");
for(i = 0; i < document.frm1.elements.length; i++) {
document.frm1.elements[i].value = currRecord[i];
}
}
}
function navigate(control) {
switch (control) {
case "first" :
recCount = 0;
currentRecord();
document.frm2.add.value = " NEW ";
break;
case "last" :
recCount = arrRecords.length - 1;
currentRecord();
document.frm2.add.value = " NEW ";
break;
case "next" :
if (recCount < arrRecords.length - 1) {
recCount = recCount + 1;
currentRecord();
document.frm2.add.value = " NEW ";
}
break;
case "previous" :
if (recCount > 0) {
recCount = recCount - 1;
currentRecord();
}
document.frm2.add.value = " NEW ";
break;
default:
}
}
function pageLoad(){
if (!Array.prototype.splice) {
function array_splice(ind,cnt) {
if (arguments.length == 0) return ind;
if (typeof ind != "number") ind = 0;
if (ind < 0) ind = Math.max(0,this.length + ind);
if (ind > this.length) {
if (arguments.length > 2) ind = this.length;
else return [];
}
if (arguments.length < 2) cnt = this.length-ind;
cnt = (typeof cnt == "number") ? Math.max(0,cnt) : 0;
removeArray = this.slice(ind,ind+cnt);
endArray = this.slice(ind+cnt);
this.length = ind;
for (var i = 2; i < arguments.length; i++) {
this[this.length] = arguments[i];
}
for(var i = 0; i < endArray.length; i++) {
this[this.length] = endArray[i];
}
return removeArray;
}
Array.prototype.splice = array_splice;
}
recCount = 0;
loadCookie();
countRecords();
}
</script>
Colocar dentro del Tag <BODY> ejemplo <Body onLoad="pageLoad()">
Colocar entre el <BODY> y </BODY>
<center>
<form name="frm1">
<table align="center" resize="none" border="0">
<tr>
<td align="right">Name:</td>
<td colspan="5"><input type="box" name="name" size="49"></td>
</tr>
<tr>
<td align="right">Address:</td><td colspan="5"><input type="box" name="address" size="49"></td></tr>
<td align="right">Address 2:</td><td colspan="5" align="left"><input type="box" name="address2" size="49"></td>
</tr>
<tr>
<td align="right">City:</td>
<td><input type="box" name="city" size="15"></td>
<td>State:</td><td><input type="box" name="state" size="15"></td>
<td>Zip:</td><td><input type="box" size="6" name="zip"></td>
</tr>
<tr>
<td align="right">Phone:</td>
<td align="left"><input type="box" name="phone" size="15"></td>
<td align="right">Fax:</td><td align="left"><input type="box" name="fax" size="15"></td>
</tr>
<tr>
<td align="right">Web Page:<td colspan="5" align="left"><input type="box" name="address" size="49"></td>
</tr>
<tr>
<td align="right">E-Mail:<td colspan="5" align="left"><input type="box" name="email" size="49"></td>
</tr>
<tr>
<td align="right" valign="top">Comments:</td>
<td colspan="5" align="left"><input type="box" name="comment1" size="49"><br>
<input type="box" name="comment2" size="49"><br>
<input type="box" name="comment3" size="49"><br>
<input type="box" name="comment4" size="49"><br>
<input type="box" name="comment5" size="49">
</td>
</tr>
</table>
</form>
<form name="frm2">
<table align="center" border="1" resize="none">
<tr>
<td align="center">
<input type="button" name="first" value="|<< " onClick="navigate('first');countRecords()">
<input type="button" name="previous" value=" < " onClick="navigate('previous');countRecords()">
<input type="button" name="next" value=" > " onClick="navigate('next');countRecords()">
<input type="button" name="last" value=" >>|" onClick="navigate('last');countRecords()">
<input type="box" name="actual" size=30>
</td>
</tr>
<tr>
<td align="center">
<input type="button" name="add" value=" NEW " onClick="newRec();countRecords()">
<input type="button" name="set" value="SAVE RECORD" onClick="setRec();countRecords()">
<input type="button" name="del" value="Delete" onClick="delRec();countRecords()">
</td>
</tr>
</table>
</form>
</center>
JAVASCRIPT: Mostrar la Última Visita de una Persona en tu Web
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function Who(info){
var VisitorName = GetCookie('VisitorName')
if (VisitorName == null) {
VisitorName = prompt("Quién eres tú ?");
SetCookie ('VisitorName', VisitorName, exp);
}
return VisitorName;
}
function When(info){
var rightNow = new Date()
var WWHTime = 0;
WWHTime = GetCookie('WWhenH')
WWHTime = WWHTime * 1
var lastHereFormatting = new Date(WWHTime);
var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()
var lastHereInDateFormat = "" + lastHereFormatting;
var dayOfWeek = lastHereInDateFormat.substring(0,3)
var dateMonth = lastHereInDateFormat.substring(4,11)
var timeOfDay = lastHereInDateFormat.substring(11,16)
var year = lastHereInDateFormat.substring(23,25)
var WWHText = dayOfWeek + ", " + dateMonth + " at " + timeOfDay
SetCookie ("WWhenH", rightNow.getTime(), exp)
return WWHText
}
function Count(info){
var WWHCount = GetCookie('WWHCount')
if (WWHCount == null) {
WWHCount = 0;
}
else{
WWHCount++;
}
SetCookie ('WWHCount', WWHCount, exp);
return WWHCount;
}
function set(){
VisitorName = prompt("Quién eres tú ?");
SetCookie ('VisitorName', VisitorName, exp);
SetCookie ('WWHCount', 0, exp);
SetCookie ('WWhenH', 0, exp);
}
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
// End -->
</SCRIPT>
ENTRE EL <BODY> Y </BODY>
<SCRIPT LANGUAGE="JavaScript">
document.write("Hola " + Who() + ". Tú estuviste aquí " + Count() + " veces. La última vez fué: " + When() +".");
</SCRIPT>
HTML: Buen Script si quieres poner un Color de Fondo Degradado a tu Página
Código:
style="filter:progid:DXImageTransform.Microsoft.Gradient( endColorstr='#C0CFE2', startColorstr='#FFFFFF', gradientType='0');"
Ejemplo:
<body style="filter:progid:DXImageTransform.Microsoft.Gradient( endColorstr='#C0CFE2', startColorstr='#FFFFFF', gradientType='0');" >
Calculadora en Consola C# (C Sharp)
{
class examen
{
static void Main(string[] args)
{
Console.Title = "Calculadora";
Console.SetCursorPosition(55, 5);
Console.Write(" : Negro");
Console.SetCursorPosition(55, 6);
Console.Write(" : Blanco");
Console.SetCursorPosition(55, 7);
Console.Write(" : Amarillo");
Console.SetCursorPosition(55, 8);
Console.Write(" : Rojo");
Console.SetCursorPosition(55, 9);
Console.Write(" : Verde");
fondo();
Console.SetCursorPosition(55, 20);
Console.Write("/1/ : Muy pequeño");
Console.SetCursorPosition(55, 21);
Console.Write("/2/ : Pequeño");
Console.SetCursorPosition(55, 22);
Console.Write("/3/ : Normal");
Console.SetCursorPosition(55, 23);
Console.Write("/4/ : Mediano");
Console.SetCursorPosition(55, 24);
Console.Write("/5/ : Grande");
tamaño();
Console.SetCursorPosition(3, 2);
int a = ingreso();
Console.SetCursorPosition(3, 3);
int b = ingreso();
Console.SetCursorPosition(55, 2);
Console.Write("(+) : suma");
Console.SetCursorPosition(55, 4);
Console.Write("(-) : resta");
Console.SetCursorPosition(55, 6);
Console.Write("(*) : multiplicacion");
Console.SetCursorPosition(55, 8);
Console.Write("(/) : division");
Console.SetCursorPosition(3, 5);
Console.Write("===========================");
Console.SetCursorPosition(3, 11);
Console.Write("===========================");
Console.SetCursorPosition(3,6);
Console.Write("operacion");
operaciones(a, b);
Console.ReadKey();
}
static int ingreso()
{
Console.Write("Ingrese el numero--> ");
int n = Int16.Parse(Console.ReadLine());
return n;
}
static void operaciones(int x, int y)
{
Console.SetCursorPosition(25, 6);
string z = Console.ReadLine();
switch (z)
{
case "+":
Console.SetCursorPosition(25, 9);
Console.Write("{0}", x + y);
resultado();
break;
case "-":
Console.SetCursorPosition(25, 9);
Console.Write("{0}", x - y);
resultado();
break;
case "*":
Console.SetCursorPosition(25, 9);
Console.Write("{0}", x * y);
resultado();
break;
case "/":
Console.SetCursorPosition(25, 9);
Console.Write("{0:0.00}", x / y);
resultado();
break;
default:
Console.Write("Error");
break;
}
}
static void fondo()
{
Console.SetCursorPosition(3, 5);
Console.Write("¡CAMBIA EL COLOR DE FONDO!^^----> ");
char f = char.Parse(Console.ReadLine());
switch (f)
{
case 'N':
Console.BackgroundColor = ConsoleColor.Black;
Console.Clear();
break;
case 'B':
Console.BackgroundColor = ConsoleColor.White;
Console.Clear();
break;
case 'A':
Console.BackgroundColor = ConsoleColor.Yellow;
Console.Clear();
break;
case 'R':
Console.BackgroundColor = ConsoleColor.Red;
Console.Clear();
break;
case 'V':
Console.BackgroundColor = ConsoleColor.DarkGreen;
Console.Clear();
break;
default:
Console.Write("Error");
break;
}
}
static void tamaño()
{
Console.SetCursorPosition(3, 18);
Console.Write("¡VAMOS..AGRANDA O ACHICA!^^----> ");
string t = Console.ReadLine();
switch (t)
{
case "1":
Console.SetWindowSize(5,10);
Console.Clear();
break;
case "2":
Console.SetWindowSize(10,20);
Console.Clear();
break;
case "3":
Console.SetWindowSize(15,25);
Console.Clear();
break;
case "4":
Console.SetWindowSize(25,35);
Console.Clear();
break;
case "5":
Console.SetWindowSize(50,59);
Console.Clear();
break;
default:
Console.Write("Error");
break;
}
}
static void resultado()
{
Console.SetCursorPosition(3, 9);
Console.Write("RESULTADO");
int res = Int16.Parse(Console.ReadLine());
}
}
}
lunes, 13 de julio de 2015
C# - Calculadora sencilla usando Metodos
using System.Collections.Generic;
using System.Linq;
using System.Text;
using c = System.Console;
/* Para más códigos visita www.zvipuapica.blogspot.com , KEHACKSOFT */
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
c.Title="Calculadora Sencilla Usando Metodos";
string s=signo();
int n1=ingreso();/*Igualamos el valor que toma
el método Ingreso() y lo asignamos a Una variable n1*/
int n2 = ingreso();/*Igualamos el valor que toma
el método Ingreso() y lo asignamos a Una variable n2*/
operacion(n1,n2,s);
denuevo();
c.ReadKey();
}
static int ingreso()
{
c.WriteLine("Ingresa un Numero");
int num = int.Parse(c.ReadLine());
return num;/*devolvemos el valor leido desde consola al metodo.
*/
}
static string signo()
{
c.WriteLine("Ingresa Una Operacion: + - * /");
string d=c.ReadLine();
return d;
}
static void operacion(int a, int b, string t)
{
switch (t)
{
case "+":
c.WriteLine("El resultado es: {0}", a + b);
break;
case "-":
c.WriteLine("El resultado es: {0}", a - b);
break;
case "*":
c.WriteLine("El resultado es: {0}", a * b);
break;
case "/":
c.WriteLine("El resultado es: {0}", a / b);
break;
default:
c.WriteLine(" ");
c.WriteLine(" ");
c.Write("¡¡¡Error!!!");
c.WriteLine(" ");
c.WriteLine(" ");
break;
}
}
static void denuevo()
{
c.WriteLine(" ");
c.WriteLine(" ");
c.WriteLine("Desea Hacer Otra Operacion: 1=Si 2=No");
string rsp=c.ReadLine();
if (rsp == "1")
{
Main();
}
else if (rsp != "1" && rsp != "2")
{
c.WriteLine(" ");
c.WriteLine(" ");
c.WriteLine("¡¡Error Introdusca Una opcion valida..!!");
denuevo();
}
else
{
c.WriteLine(" ");
c.WriteLine(" ");
c.WriteLine("Gracias por Usar esta calculadora");
}
}
}
}
C# - Registro de Notas Usando Arrays
using System.Collections.Generic;
using System.Linq;
using System.Text;
/*Para más códigos visita www.zvipuapica.blogspot.com, KEHACKSOFT */
/*using c = System.Console;*/
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Title="Registrando Notas…!";
Console.BackgroundColor=ConsoleColor.Red;
Console.ForegroundColor=ConsoleColor.Yellow;
Console.Clear();
int cont=0; string s=" "; string p=" ";
inicio(ref p, ref s, ref cont);
int[] num=new int[cont];
string[] alumnos=new string[cont];
float[]parcial=new float[cont];
float[]pfinal=new float[cont];
float[]promedio=new float[cont];
string[] estado=new string[cont];
ingreso(ref alumnos, ref parcial, ref pfinal);
promov(ref promedio, ref estado, ref parcial, ref pfinal, ref num);
Console.Clear();
salida(p,s,num,alumnos,parcial,pfinal,promedio,estado);
Console.ReadKey();
}
static void inicio(ref string nd, ref string nc, ref int na)
{
Console.WriteLine("Nombre del Docente");
nd=Console.ReadLine();
Console.WriteLine("Nombre de la Asignatura");
nc=Console.ReadLine();
Console.WriteLine("Número de Alumnos");
na=Int16.Parse(Console.ReadLine());
Console.Clear();
}
static void ingreso(ref string[] h, ref float[]a, ref float[]r)
{
for (int i = 0; i < a.Length; i++)
{
Console.WriteLine("Nombre del Alumno");
h[i] =Console.ReadLine();
Console.WriteLine("Nota del Parcial");
a[i] =float.Parse(Console.ReadLine());
Console.WriteLine("Nota del Parcial Final");
r[i] =float.Parse(Console.ReadLine());
Console.Clear();
}
}
static void promov(ref float[] z, ref string[] x, ref float[] c, ref float[]v, ref int[]b)
{
for (int i=0; i {
b[i]=i+1;
}
for(int i=0; i
z[i]=(c[i]+v[i])/2;
for (int k=0; k
if (z[k]<10 .5="" br=""> x[k]="Desaprobado";
else
x[k]="Aprobado";
}
}
}
static void salida(string a, string s, int[] d, string[] f, float[] g, float[] h, float[] j, string[] k)
{
Console.WriteLine("Nombre del Docente: {0}", a);
Console.WriteLine("Nombre del curso: {0}", s);
Console.SetCursorPosition(0,3);
Console.Write("Numero");
Console.SetCursorPosition(7,3);
Console.Write("Alumno");
Console.SetCursorPosition(32,3);
Console.Write("Parcial");
Console.SetCursorPosition(40,3);
Console.Write("Parcial-Final");
Console.SetCursorPosition(54,3);
Console.Write("Promedio");
Console.SetCursorPosition(65,3);
Console.Write("Estado");
for (int i=0; i
Console.SetCursorPosition(1, i+5);
Console.WriteLine(d[i]);
Console.SetCursorPosition(12, i + 5);
Console.WriteLine(f[i]);
Console.SetCursorPosition(35, i + 5);
Console.WriteLine(g[i]);
Console.SetCursorPosition(46, i + 5);
Console.WriteLine(h[i]);
Console.SetCursorPosition(56, i + 5);
Console.WriteLine(j[i]);
Console.SetCursorPosition(65, i + 5);
Console.WriteLine(k[i]);
}
}
}
}
domingo, 12 de julio de 2015
Estamos de Vuelta!
Proyectos Universitarios de Programación Digital.
Los códigos son totalmente Gratis.
miércoles, 15 de septiembre de 2010
JAVA Netbeans: Area y Perimetro de un Triangulo Isoseles
-->
martes, 14 de septiembre de 2010
JAVA Netbeans: Que tipo de triangulo es solo x sus Lados? y calcular area y perimetro del triangulo Isoseles
He creado 5 clases están enumeradas...!
1.- Work (Main)
package trabajo;
/**
*
* @author KEHACKSOFT
*/
public class work {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
ingresodatos ing=new ingresodatos();
ing.ingreso();
triangulo_isoseles obj=new triangulo_isoseles(ing.getladoA(),ing.getladoB(),ing.getladoC());
obj.triangulo();
}
}
2.- IngresaDatos
package trabajo;
import javax.swing.JOptionPane;
/**
*
* @author KEHACKSOFT
*/
public class ingresodatos {
int a,b,c;
void ingreso()
{
c=Integer.parseInt(JOptionPane.showInputDialog("Ingresa LADO C (BASE): ",""));
a=Integer.parseInt(JOptionPane.showInputDialog("Ingresa LADO A: ",""));
b=Integer.parseInt(JOptionPane.showInputDialog("Ingresa LADO B: ",""));
}
public int getladoA()
{
return a;
}
public int getladoB()
{
return b;
}
public int getladoC()
{
return c;
}
}
3.- triangulo_isoseles
package trabajo;
import javax.swing.JOptionPane;
/**
*
* @author kEHCKSOFT
*/
public class triangulo_isoseles {
//public int catetoA,catetoB,
public double a, b, c; // tamaño de los lados
public double A, B, C; // angulos
public double suma;
//MI CONSTRUCTOR
triangulo_isoseles(int LadoA,int LadoB,int LadoC)
{
a=LadoA;
b=LadoB;
c=LadoC;
}
void triangulo()
{
A = Math.acos( (b * b + c * c - a * a) / (2 * b * c)) * 180 / Math.PI;
B = Math.acos( (a * a + c * c - b * b) / (2 * a * c)) * 180 / Math.PI;
C = Math.acos( (a * a + b * b - c * c) / (2 * a * b)) * 180 / Math.PI;
suma = A + B + C;
JOptionPane.showMessageDialog(null,"Los lados son = [ " + a + ", " + b + ", " +c + "]\n "
+ "Los angulos son = [ " + A + ", " + B + ", " +C + "]\n"
+"La suma de sus angulos es = " + suma);
if (A != B && B != C && C != A)
JOptionPane.showMessageDialog(null,"Es un triangulo escaleno");
}
}
}
}
}
}
4.- Area
package trabajo;
import javax.swing.JOptionPane;
/**
*
* @author KEHACKSOFT
*/
public class area {
double area1,base,altura,basetriangulorectangulo,lado;
area(double a, double c)
{
lado=a;
base=c;
}
void trianguloisoseles()
{
basetriangulorectangulo=base/2;//La altura de un triángulo isósceles divide a la base en dos segmentos iguales.
altura=Math.sqrt(Math.pow(lado, 2)-Math.pow(basetriangulorectangulo, 2));
area1=(base*altura)/2;
JOptionPane.showMessageDialog(null,"El area del Triangulo isoseles es: "+area1);
}
}
5.- Perimetro
package trabajo;
import javax.swing.JOptionPane;
/**
*
* @author KEHACKSOFT
*/
public class perimetro {
double lado,base,perimetro1;
perimetro(double a, double c)
{
lado=a;
base=c;
}
void isoseles()
{
perimetro1=(2*lado)+base;
JOptionPane.showMessageDialog(null,"El perímetro del triangulo Isoseles es..."+perimetro1);
}
}
domingo, 12 de septiembre de 2010
C sharp: Busqueda de un Numero en un Array
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{//la variable "cont" me almacenara el numero de veces que un numero se repite...
//la variable "num" me almacena el numero buscado...
//Creao mi array que me almacenara la cantidad de numeros ingresado por teclado
public int cont,num;
public int[] array1;
//Creo el constructor inicializando los valores....
Program()
{
cont = 0;
num = 0;
array1 = new int[50];//le asigno 50 espacios a mi array
}
//Mi metodo Principal(Main) aqui creo el objeto que me llamara al Metodo ingreso...
static void Main(string[] args)
{
Program obj = new Program();
obj.ingreso();
}
void ingreso()
{
for (int i = 0; i < array1.Length; i++)
{
Console.WriteLine("Ingresa Nº: " + (i + 1));
array1[i] = int.Parse(Console.ReadLine());
}
Console.WriteLine("Buscas Algun Número?... Escribelo");
num = int.Parse(Console.ReadLine());
for (int i = 0; i < array1.Length; i++)
{
if (num == array1[i])//busco en mi array numero iguales
{
cont++;
//almaceno el numero que se esta repitiendo en otro array
}
}
Console.WriteLine("El número " + num + " se repite " + cont + " veces.");
Console.ReadKey();
}
}
}
JAVA Netbeans: Juego Dado apuesta.... usando Jlist
Primera Clase (Main)
package jlistjava;
/**
* @author harold
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
JFrame1 harold = new JFrame1();
harold.show();
}
}
y la otra clase del Formulario que la llamare (JFrame1)
package jlistjava;
import java.util.Random;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
/**
* @author Harold
*/
public class JFrame1 extends javax.swing.JFrame {
//CREANDO MI CONSTRUCTOR
public JFrame1() {
initComponents();
modelo = new DefaultListModel();
LISTA.setModel(modelo);
}
//CODIGO GENERADO AUTOMATICAMENTE
//
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
LISTA = new javax.swing.JList();
jPanel2 = new javax.swing.JPanel();
cmdAnadir = new javax.swing.JButton();
cmdRemover = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("DADO DE APUESTA (K.Harold Choque Kaneko)");
jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
LISTA.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
LISTA.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
LISTA.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
LISTAValueChanged(evt);
}
});
jScrollPane1.setViewportView(LISTA);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 254, Short.MAX_VALUE)
.addContainerGap())
);
jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
cmdAnadir.setText("Añadir");
cmdAnadir.setCursor(new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR));
cmdAnadir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdAnadirActionPerformed(evt);
}
});
cmdRemover.setText("Remover");
cmdRemover.setCursor(new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR));
cmdRemover.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdRemoverActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(cmdRemover, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
.addComponent(cmdAnadir, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(cmdAnadir, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdRemover, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
pack();
}//
private void cmdAnadirActionPerformed(java.awt.event.ActionEvent evt) {
ingreso=Integer.parseInt(JOptionPane.showInputDialog("Ingresa tu apuesta",""));
aleatorio();
}
public void aleatorio()
{int num;
Random rand =new Random();
num=rand.nextInt(6);
if(num!=0)
{
switch (num) {
case 1:
jLabel1.setText("Haz ganado un 50% más de tu apuesta: " +(ingreso*1.5));
break;
case 2:
case 3:
case 4:
case 5:
jLabel1.setText("No haz ganado nada");
break;
case 6:
jLabel1.setText("Haz ganado 100% más de tu apuesta: "+(ingreso*2));
break;
}
modelo.addElement(num);
}
else{ aleatorio(); }
}
private void cmdRemoverActionPerformed(java.awt.event.ActionEvent evt) {
if (Seleccion>=0){
modelo.removeElementAt(Seleccion);
}
jLabel1.setText("");
}
private void LISTAValueChanged(javax.swing.event.ListSelectionEvent evt) {
Seleccion = LISTA.getSelectedIndex();
}
/**
* @param args the command line arguments
*/
DefaultListModel modelo ;
String name = "";
int Seleccion = -1;
int ingreso=0;
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JFrame1().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JList LISTA;
private javax.swing.JButton cmdAnadir;
private javax.swing.JButton cmdRemover;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration
}
Descarga el Código desde Aqui
domingo, 29 de agosto de 2010
JAVA: Dado el número que identifica al mes (del 1 al 12) imprimir el nombre del mes.
public static void main(String[] args) {
int mes=3;
switch (mes) {
case 1: System.out.println("Enero"); break;
case 2: System.out.println("Febrero"); break;
case 3: System.out.println("Marzo"); break;
case 4: System.out.println("Abril"); break;
case 5: System.out.println("Mayo"); break;
case 6: System.out.println("Junio"); break;
case 7: System.out.println("Julio"); break;
case 8: System.out.println("Agosto"); break;
case 9: System.out.println("Septiembre"); break;
case 10: System.out.println("Octubre"); break;
case 11: System.out.println("Noviembre"); break;
case 12: System.out.println("Diciembre"); break;
default: System.out.println("Este mes no existe"); break;
}
}
}
Programilla Año bisiesto en JAVA
public static void main(String[] args) {
int mes=2;
int año=1992;
int numDias=30;
switch (mes) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
numDias = 31;
break;
case 4:
case 6:
case 9:
case 11:
numDias = 30;
break;
case 2:
if ( ((año % 4 == 0) && !(año % 100 == 0)) (año % 400 == 0) )
numDias = 29;
else
numDias = 28;
break;
default:
System.out.println("Este mes no existe");
break;
}
System.out.println("El mes "+mes+" del año "+año+" tiene "+numDias+" días");
}
}
miércoles, 26 de mayo de 2010
C # :: Ingresar "N" número de Nombres y Ordenarlos Alfabeticamente
Variables: pnomb="Primer Nombre" y apepat="Apellido Paterno"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using c = System.Console;
/*Creacion de KehackSoft
*más códigos en www.zvipuapica.blogspot.com
*/
namespace ejercicio1
{
class ejercicio2
{
string[] pnomb;
string[] apepat;
int num;
ejercicio2(int nume)
{
num = nume;
pnomb=new string[num];
apepat=new string[num];
}
void Ingreso()
{
for (int i = 0; i <num;i++)
{
c.WriteLine("");
c.WriteLine("Ingresa Primer Nombre");
pnomb[i] = c.ReadLine();
c.WriteLine("Ingresa Apellido Paterno");
apepat[i] = c.ReadLine();
c.WriteLine("");
}
}
//SE HACEN EL CAMBIO DE VARIABLES PARA ORDENAR ALFABETICAMENTE LOS NOMBRES
void ordena()
{
String auxNom,auxAp ;
for (int i = 0; i <n-1;i++)
{
for (int j = i + 1; j <n;j++)
{
if (pnomb[i].CompareTo(pnomb[j])>0)
{
auxNom = pnomb[i];
auxAp = apepat[i];
pnomb[i] = pnomb[j];
apepat[i]=apepat[j];
pnomb[j] = auxNom;
apepat[j] = auxAp;
}
}
}
}
void mostrar()
{
c.WriteLine("");
c.WriteLine("");
c.WriteLine("Lista de Nombres Ordenados.");
c.WriteLine("--------------------------");
c.WriteLine("");
for (int i = 0; i <n;i++)
{
c.WriteLine((i+1)+") {0} {1}",pnomb[i],apepat[i]);
}
}
void continuar()
{
c.WriteLine("¿Desea Continuar?---- SI-NO");
String rsp = c.ReadLine();
if (rsp == "SI")
{
c.Clear();
Main();
}
else
{
c.WriteLine("");
c.WriteLine("Nos vemos...!");
}
}
static void Main()
{
c.WriteLine("Ingresa la Cantidad de Alumnos");
int num = int.Parse(c.ReadLine());
ejercicio2 a = new ejercicio2(num);
a.Ingreso();
a.ordena();
a.mostrar();
a.continuar();
c.ReadLine();
}
}
}