Commit 50399e39 by Matias Ferreira

agregando detalles aprendidos en la clase de hoy

parent f4ce1947
package com.roshka.webprojecttest.servlets;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/factorial")
public class FactorialRequestServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
// req -> datos que envia el navegador al servidor de aplicaciones
// resp -> la respuesta que envia el servidor de aplicaciones al navegador
PrintWriter pw = new PrintWriter(resp.getOutputStream());
// String s1 = req.getParameter("s1");
// String s2 = req.getParameter("s2");
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos factorializador</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un factorializador</h1>"
+ "<div>"
+ "<form action=\"factorial-response\" >"
+ "Introduzca el numero: <input type=\"text\" name=number><br>"
+ "<input type=\"submit\">"
+ "</form>"
+ "</div>"
+ "</body>"
+ "</html>");
pw.close();
}
}
...@@ -10,80 +10,116 @@ import javax.servlet.http.HttpServlet; ...@@ -10,80 +10,116 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@WebServlet("/factorial-response") @WebServlet("/factorial")
public class FactorialResponseServlet extends HttpServlet { public class FactorialServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse resp) protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException throws ServletException, IOException
{ {
PrintWriter pw = new PrintWriter(resp.getOutputStream()); PrintWriter pw = new PrintWriter(resp.getOutputStream());
Boolean valido=true; Boolean valido=true;
String parametro = req.getParameter("number"); String parametro = req.getParameter("number");
if(parametro.length() <1) if(parametro == null ) {
valido=false; initForm(pw);
for(int i = 0 ; i < parametro.length(); i++) {
if( ( !Character.isDigit(parametro.charAt(i)) && i > 0) && !(Character.isDigit(parametro.charAt(i)) && i == 0 && parametro.charAt(i) != '-' ) ) {
valido=false;
break;
}
}
if (!valido) {
pw.write("<html>"
+ "<head>"
+ "<title>Error de parametro</title>"
+ "</head>"
+ "<body>"
+ "No se puede generarla tabla de multiplicar. Valor del parametro \" " + parametro + " \" invalido."
+ "</body>"
+ "</html>");
} }
else { else {
Integer numero = Integer.parseInt(parametro);
if(numero > 100) { if(parametro.equals(""))
pw.write("<html>" valido=false;
+ "<head>" for(int i = 0 ; i < parametro.length(); i++) {
+ "<title>Error de parametro</title>" if( ( !Character.isDigit(parametro.charAt(i)) && i > 0) && !(Character.isDigit(parametro.charAt(i)) && i == 0 && parametro.charAt(i) != '-' ) ) {
+ "</head>" valido=false;
+ "<body>" break;
+ "Mi programa solo conoce el factorial de hasta el numero 100. El numero pasado fue: "+numero }
+ "</body>"
+ "</html>");
} }
else if(numero<0) { if (!valido) {
pw.write("<html>" error(pw, parametro);
+ "<head>"
+ "<title>Error de parametro</title>"
+ "</head>"
+ "<body>"
+ "Mi programa no sabe obtener el factorial de numeros negativos"
+ "</body>"
+ "</html>");
} }
else{ else {
long facto=1; Integer numero = Integer.parseInt(parametro);
for (long i = 2; i <=numero;i++) if(numero > 100) {
facto*=i; greaterThan100(pw, numero);
pw.write("<html>" }
+ "<head>" else if(numero<0) {
+ "<title>Hola, bienvenidos al factorializador</title>" negative(pw);
+ "</head>" }
+ "<body>" else{
+ "<h1>Soy un generador de factorial de numeros</h1>" long facto=1;
+ "<div>" for (long i = 2; i <=numero;i++)
+ "<form action=\"factorial-response\" >" facto*=i;
+ "Introduzca el numero: <input type=\"text\" name=number><br>" factoDisplay(pw, numero, facto);
+ "<input type=\"submit\">" }
+ "</form>"
+ "</div>"
+ "<div>"
+ "<p>El factorial de "+ numero+" es: " + facto +"</p>"
+ "</div>"
+ "</body>"
+ "</html>");
} }
} }
pw.close(); pw.close();
} }
void factoDisplay(PrintWriter pw, Integer numero, Long facto) {
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos al factorializador</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un generador de factorial de numeros</h1>"
+ "<div>"
+ "<form action=\"factorial-response\" >"
+ "Introduzca el numero: <input type=\"text\" name=number><br>"
+ "<input type=\"submit\">"
+ "</form>"
+ "</div>"
+ "<div>"
+ "<p>El factorial de "+ numero+" es: " + facto +"</p>"
+ "</div>"
+ "</body>"
+ "</html>");
}
void error(PrintWriter pw, String parametro) {
pw.write("<html>"
+ "<head>"
+ "<title>Error de parametro</title>"
+ "</head>"
+ "<body>"
+ "No se puede generarla tabla de multiplicar. Valor del parametro \" " + parametro + " \" invalido."
+ "</body>"
+ "</html>");
}
void greaterThan100(PrintWriter pw, Integer numero) {
pw.write("<html>"
+ "<head>"
+ "<title>Error de parametro</title>"
+ "</head>"
+ "<body>"
+ "Mi programa solo conoce el factorial de hasta el numero 100. El numero pasado fue: "+numero
+ "</body>"
+ "</html>");
}
void negative(PrintWriter pw) {
pw.write("<html>"
+ "<head>"
+ "<title>Error de parametro</title>"
+ "</head>"
+ "<body>"
+ "Mi programa no sabe obtener el factorial de numeros negativos"
+ "</body>"
+ "</html>");
}
void initForm(PrintWriter pw) {
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos factorializador</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un factorializador</h1>"
+ "<div>"
+ "<form action=\"factorial-response\" >"
+ "Introduzca el numero: <input type=\"text\" name=number><br>"
+ "<input type=\"submit\">"
+ "</form>"
+ "</div>"
+ "</body>"
+ "</html>");
}
} }
package com.roshka.webprojecttest.servlets;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/show-me-the-bits")
public class ShowMeTheBitsRequestServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
PrintWriter pw = new PrintWriter(resp.getOutputStream());
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos al show me the bits</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un conversor sistemas de numeracion</h1>"
+ "<div>"
+ "<form action=\"show-me-the-bits-response\" >"
+ "Introduzca el numero: <input type=\"text\" name=number><br>"
+ "<input type=\"submit\">"
+ "</form>"
+ "</div>"
+ "</body>"
+ "</html>");
pw.close();
}
}
...@@ -11,8 +11,8 @@ import javax.servlet.http.HttpServlet; ...@@ -11,8 +11,8 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@WebServlet("/show-me-the-bits-response") @WebServlet("/show-me-the-bits")
public class ShowMeTheBitsResponseServlet extends HttpServlet { public class ShowMeTheBitsServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse resp) protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException throws ServletException, IOException
{ {
...@@ -20,100 +20,128 @@ public class ShowMeTheBitsResponseServlet extends HttpServlet { ...@@ -20,100 +20,128 @@ public class ShowMeTheBitsResponseServlet extends HttpServlet {
Boolean valido=true; Boolean valido=true;
String parametro = req.getParameter("number"); String parametro = req.getParameter("number");
Integer [] vectorResultado = new Integer [16]; Integer [] vectorResultado = new Integer [16];
String tipo=""; if(parametro == null) {
if(parametro.length() < 1) initForm(pw);
valido=false;
else if(parametro.length() >1 ) {
if(parametro.charAt(0) == '0') {
if(parametro.charAt(1) == 'x')
tipo = "hexadecimal";
else
tipo = "octal";;
}else
tipo="decimal";
}else
tipo= "decimal";;
if(tipo.equals("decimal")) {
for ( int i = 0 ; i< parametro.length(); i++)
if(!Character.isDigit(parametro.charAt(i)))
valido = false;
}
else if(tipo.equals("octal")) {
for ( int i = 1 ; i< parametro.length(); i++)
if(!Character.isDigit(parametro.charAt(i)))
valido = false;
}
else if(tipo.equals("hexadecimal")) {
for ( int i = 2 ; i < parametro.length(); i++ )
if( !isHexaDigit(parametro.charAt(i) ) )
valido = false;
}
int validAux = 0;
if(valido) {
if(tipo.equals("decimal") )
validAux = Integer.parseInt(parametro,10);
else if( tipo.equals("hexadecimal") )
validAux = Integer.parseInt(parametro.substring(2),16);
else
validAux = Integer.parseInt(parametro.substring(1),8);
}
if(validAux > 65535)
valido = false;
if (!valido) {
pw.write("<html>"
+ "<head>"
+ "<title>Error de parametro</title>"
+ "</head>"
+ "<body>"
+ "No se puede generarla tabla de multiplicar. Valor del parametro \"" + parametro + "\" invalido."
+ "</body>"
+ "</html>");
} }
else { else {
transformacion(tipo, parametro, vectorResultado); String tipo="";
if(parametro.length() < 1)
pw.write("<html>" valido=false;
+ "<head>" else if(parametro.length() >1 ) {
+ "<title>Hola, bienvenidos al conversor de numeros</title>" if(parametro.charAt(0) == '0') {
+ "</head>" if(parametro.charAt(1) == 'x')
+ "<body>" tipo = "hexadecimal";
+ "<h1>Soy un conversor de sistemas de numeracion</h1>" else
+ "<div>" tipo = "octal";;
+ "<form action=\"show-me-the-bits-response\" >" }else
+ "Introduzca el numero: <input type=\"text\" name=number><br>" tipo="decimal";
+ "<input type=\"submit\">" }else
+ "</form>" tipo= "decimal";;
+ "</div>"
+ "<table>" if(tipo.equals("decimal")) {
+ "<tr>"); for ( int i = 0 ; i< parametro.length(); i++)
for(int i = 15; i >= 0 ; i--) { if(!Character.isDigit(parametro.charAt(i)))
if(vectorResultado[i] == 1) { valido = false;
pw.write("<th style=\"color: gold ; background-color:darkblue;\">" + vectorResultado[i]+"</th>");
} }
else { else if(tipo.equals("octal")) {
pw.write("<th style=\"color:fuchsia ; background-color:darkblue;\">"+vectorResultado[i]+"</th>"); for ( int i = 1 ; i< parametro.length(); i++)
if(!Character.isDigit(parametro.charAt(i)))
valido = false;
} }
if(i == 8) { else if(tipo.equals("hexadecimal")) {
pw.write("<th> === </th>"); for ( int i = 2 ; i < parametro.length(); i++ )
if( !isHexaDigit(parametro.charAt(i) ) )
valido = false;
} }
else if(i == 0) { int validAux = 0;
pw.write("</tr>"); if(valido) {
if(tipo.equals("decimal") )
validAux = Integer.parseInt(parametro,10);
else if( tipo.equals("hexadecimal") )
validAux = Integer.parseInt(parametro.substring(2),16);
else
validAux = Integer.parseInt(parametro.substring(1),8);
}
if(validAux > 65535)
valido = false;
if (!valido) {
invalido(pw, parametro);
}
else {
transformacion(tipo, parametro, vectorResultado);
theTable(pw, vectorResultado);
} }
else
pw.write("<th> | </th>");
}
pw.write( "</table>"
+ "</body>"
+ "</html>");
} }
pw.close(); pw.close();
} }
void initForm(PrintWriter pw) {
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos al show me the bits</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un conversor sistemas de numeracion</h1>"
+ "<div>"
+ "<form action=\"show-me-the-bits\" >"
+ "Introduzca el numero: <input type=\"text\" name=number><br>"
+ "<input type=\"submit\">"
+ "</form>"
+ "</div>"
+ "</body>"
+ "</html>");
}
void theTable(PrintWriter pw, Integer [] vectorResultado) {
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos al conversor de numeros</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un conversor de sistemas de numeracion</h1>"
+ "<div>"
+ "<form action=\"show-me-the-bits\" >"
+ "Introduzca el numero: <input type=\"text\" name=number><br>"
+ "<input type=\"submit\">"
+ "</form>"
+ "</div>"
+ "<table>"
+ "<tr>");
for(int i = 15; i >= 0 ; i--) {
if(vectorResultado[i] == 1) {
pw.write("<th style=\"color: gold ; background-color:darkblue;\">" + vectorResultado[i]+"</th>");
}
else {
pw.write("<th style=\"color:fuchsia ; background-color:darkblue;\">"+vectorResultado[i]+"</th>");
}
if(i == 8) {
pw.write("<th> === </th>");
}
else if(i == 0) {
pw.write("</tr>");
}
else
pw.write("<th> | </th>");
}
pw.write( "</table>"
+ "</body>"
+ "</html>");
}
void invalido(PrintWriter pw, String parametro) {
pw.write("<html>"
+ "<head>"
+ "<title>Error de parametro</title>"
+ "</head>"
+ "<body>"
+ "No se puede generarla tabla de bits. Valor del parametro \"" + parametro + "\" invalido."
+ "</body>"
+ "</html>");
}
public void transformacion(String tipo, String valor, Integer [] resultado) { public void transformacion(String tipo, String valor, Integer [] resultado) {
if(tipo.equals("decimal")) { if(tipo.equals("decimal")) {
......
...@@ -18,22 +18,41 @@ public class SumaRequestServlet extends HttpServlet { ...@@ -18,22 +18,41 @@ public class SumaRequestServlet extends HttpServlet {
{ {
PrintWriter pw = new PrintWriter(resp.getOutputStream()); PrintWriter pw = new PrintWriter(resp.getOutputStream());
String s1 = req.getParameter("s1");
String s2 = req.getParameter("s2");
if(s1 != null && s2 != null) {
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos al sumador</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un sumador</h1>"
+ "<div>"
+ "<p>Operador s1: " + s1 + "</p>"
+ "<p>Operador s2: " + s2 + "</p>"
+ "<p>s1 + s2: " + (Double.parseDouble(s1) + Double.parseDouble(s2)) + "</p>"
+ "</div>"
+ "</body>"
+ "</html>");
}else {
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos al sumador</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un sumador</h1>"
+ "<div>"
+ "<form action=\"suma\">"
+ "Enter 1st number: <input type=\"text\" name=s1><br>"
+ "Enter 2nd number: <input type=\"text\" name=s2><br>"
+ "<input type=\"submit\">"
+ "</form>"
+ "</div>"
+ "</body>"
+ "</html>");
}
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos al sumador</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un sumador</h1>"
+ "<div>"
+ "<form action=\"suma-response\">"
+ "Enter 1st number: <input type=\"text\" name=s1><br>"
+ "Enter 2nd number: <input type=\"text\" name=s2><br>"
+ "<input type=\"submit\">"
+ "</form>"
+ "</div>"
+ "</body>"
+ "</html>");
pw.close(); pw.close();
......
package com.roshka.webprojecttest.servlets;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/tabla-multiplicar")
public class TablaMultiplicarRequestServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
PrintWriter pw = new PrintWriter(resp.getOutputStream());
pw.write("<html>"
+ "<head>"
+ "<title>Hola, Aqui te enseño las tablas de la multiplicacion</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un generador de tablas de multiplicar</h1>"
+ "<div>"
+ "<form action=\"tabla-multiplicar-response\">"
+ "Enter 1st number: <input type=\"text\" name=number><br>"
+ "<input type=\"submit\">"
+ "</form>"
+ "</div>"
+ "</body>"
+ "</html>");
pw.close();
}
}
...@@ -10,85 +10,121 @@ import javax.servlet.http.HttpServlet; ...@@ -10,85 +10,121 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@WebServlet("/tabla-multiplicar-response") @WebServlet("/tabla-multiplicar")
public class TablaMultiplicarResponseServelet extends HttpServlet { public class TablaMultiplicarServelet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse resp) protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException throws ServletException, IOException
{ {
PrintWriter pw = new PrintWriter(resp.getOutputStream()); PrintWriter pw = new PrintWriter(resp.getOutputStream());
Boolean valido=true; Boolean valido=true;
String parametro = req.getParameter("number"); String parametro = req.getParameter("number");
if(parametro.length() <1) if(parametro == null) {
valido=false; initForm(pw);
for(int i = 0 ; i < parametro.length(); i++) { }else {
if( ( !Character.isDigit(parametro.charAt(i)) && i > 0) && !(Character.isDigit(parametro.charAt(i)) && i == 0 && parametro.charAt(i) != '-' ) ) {
if(parametro.length() <1)
valido=false; valido=false;
break; for(int i = 0 ; i < parametro.length(); i++) {
if( ( !Character.isDigit(parametro.charAt(i)) && i > 0) && !(Character.isDigit(parametro.charAt(i)) && i == 0 && parametro.charAt(i) != '-' ) ) {
valido=false;
break;
}
} }
} if (!valido) {
if (!valido) { invalid(pw, parametro);
pw.write("<html>"
+ "<head>"
+ "<title>Error de parametro</title>"
+ "</head>"
+ "<body>"
+ "No se puede generarla tabla de multiplicar. Valor del parametro \"" + parametro + "\" invalido."
+ "</body>"
+ "</html>");
}
else {
Integer numero = Integer.parseInt(parametro);
if(numero > 100) {
pw.write("<html>"
+ "<head>"
+ "<title>Error de parametro</title>"
+ "</head>"
+ "<body>"
+ "Mi programa solo conoce la tabla de multiplicar hasta el numero 100. El numero pasado fue: "+numero
+ "</body>"
+ "</html>");
} }
else if(numero<0) { else {
pw.write("<html>" Integer numero = Integer.parseInt(parametro);
+ "<head>" if(numero > 100) {
+ "<title>Error de parametro</title>" greaterThan100(pw, numero);
+ "</head>"
+ "<body>" }
+ "Mi programa no sabe las tablas de multiplicar de numeros negativos" else if(numero<0) {
+ "</body>" negative(pw);
+ "</html>");
} }
else{ else{
pw.write("<html>" theTable(pw, numero);
+ "<head>" }
+ "<title>Hola, bienvenidos al multiplicador</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un generador de tablas de multiplicar</h1>"
+ "<div>"
+ "<form action=\"tabla-multiplicar-response\">"
+ "Enter 1st number: <input type=\"text\" name=number><br>"
+ "<input type=\"submit\">"
+ "</form>"
+ "</div>"
+ "<table style=\"width:5%\">"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>1 </th>" +"<th>=</th>" + "<th>"+(numero*1) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>2 </th>" +"<th>=</th>" + "<th>"+(numero*2) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>3 </th>" +"<th>=</th>" + "<th>"+(numero*3) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>4 </th>" +"<th>=</th>" + "<th>"+(numero*4) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>5 </th>" +"<th>=</th>" + "<th>"+(numero*5) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>6 </th>" +"<th>=</th>" + "<th>"+(numero*6) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>7 </th>" +"<th>=</th>" + "<th>"+(numero*7) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>8 </th>" +"<th>=</th>" + "<th>"+(numero*8) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>9 </th>" +"<th>=</th>" + "<th>"+(numero*9) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>10</th>" +"<th>=</th>" + "<th>"+(numero*10)+ "</th>" + "</tr>"
+ "</tdr>"
+ "</body>"
+ "</html>");
} }
} }
pw.close(); pw.close();
} }
void initForm(PrintWriter pw) {
pw.write("<html>"
+ "<head>"
+ "<title>Hola, Aqui te enseño las tablas de la multiplicacion</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un generador de tablas de multiplicar</h1>"
+ "<div>"
+ "<form action=\"tabla-multiplicar\">"
+ "Enter 1st number: <input type=\"text\" name=number><br>"
+ "<input type=\"submit\">"
+ "</form>"
+ "</div>"
+ "</body>"
+ "</html>");
}
void theTable(PrintWriter pw, Integer numero) {
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos al multiplicador</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un generador de tablas de multiplicar</h1>"
+ "<div>"
+ "<form action=\"tabla-multiplicar\">"
+ "Enter 1st number: <input type=\"text\" name=number><br>"
+ "<input type=\"submit\">"
+ "</form>"
+ "</div>"
+ "<table style=\"width:5%\">"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>1 </th>" +"<th>=</th>" + "<th>"+(numero*1) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>2 </th>" +"<th>=</th>" + "<th>"+(numero*2) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>3 </th>" +"<th>=</th>" + "<th>"+(numero*3) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>4 </th>" +"<th>=</th>" + "<th>"+(numero*4) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>5 </th>" +"<th>=</th>" + "<th>"+(numero*5) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>6 </th>" +"<th>=</th>" + "<th>"+(numero*6) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>7 </th>" +"<th>=</th>" + "<th>"+(numero*7) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>8 </th>" +"<th>=</th>" + "<th>"+(numero*8) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>9 </th>" +"<th>=</th>" + "<th>"+(numero*9) + "</th>" + "</tr>"
+ "<tr>"+ "<th>"+numero+"</th>" + "<th>*</th>"+ "<th>10</th>" +"<th>=</th>" + "<th>"+(numero*10)+ "</th>" + "</tr>"
+ "</tdr>"
+ "</body>"
+ "</html>");
}
void invalid(PrintWriter pw, String parametro) {
pw.write("<html>"
+ "<head>"
+ "<title>Error de parametro</title>"
+ "</head>"
+ "<body>"
+ "No se puede generarla tabla de multiplicar. Valor del parametro \"" + parametro + "\" invalido."
+ "</body>"
+ "</html>");
}
void greaterThan100(PrintWriter pw, Integer numero) {
pw.write("<html>"
+ "<head>"
+ "<title>Error de parametro</title>"
+ "</head>"
+ "<body>"
+ "Mi programa solo conoce la tabla de multiplicar hasta el numero 100. El numero pasado fue: "+numero
+ "</body>"
+ "</html>");
}
void negative(PrintWriter pw) {
pw.write("<html>"
+ "<head>"
+ "<title>Error de parametro</title>"
+ "</head>"
+ "<body>"
+ "Mi programa no sabe las tablas de multiplicar de numeros negativos"
+ "</body>"
+ "</html>");
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment