Armen du er en skat Kevin.
Du burde fandme have en stor julemand sendt afsted.
Til andre som har interesse så er det endt ud således:
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
- package caltab;
-
- import java.io.File;
- import java.io.PrintWriter;
-
-
-
-
-
- /**
- *
- * @author Daniel Mautone PB17
- */
-
-
-
- public class CalTab {
-
-
- public static void main(String[] args) {
- int[][] table = new int[10][10];
-
- try{
- PrintWriter writer = new PrintWriter(new File("index.html"));
- //Add html header
- writer.println("<!DOCTYPE html>");
- writer.println("<html>\n<body>\n");
-
-
- //Gange udførslen
- for(int i = 0; i < 10; i++){
- for(int j = 0; j < 10; j++){
- table[i][j] = (i+1)*(j+1);
- }
- }
-
-
- //Udfører 1-10 horisontalt
- writer.println("<table><tr><td></td>");
- for(int i = 0; i < 10; i++){
- if(i % 2 == 0){
- writer.println("<td style='color: red;'>"+(i+1)+"</td>");
- } else {
- writer.println("<td style='color: blue;'>"+(i+1)+"</td>");
- }
- }
- writer.println("</tr>");
-
- //Udfører vertikalt samt udskriver gange delen
- for(int i = 0; i < 10; i++){
- if(i % 2 == 0){
- writer.println("<tr><td style='color: red;'>"+(i+1)+"</td>");
- } else {
- writer.println("<tr><td style='color: blue;'>"+(i+1)+"</td>");
- }
- for(int n = 0; n < 10; n++){
- if(n % 2 == 0){
- writer.println("<td style='color: red;'>"+table[i][n]+"</td>");
- } else {
- writer.println("<td style='color: blue;'>"+table[i][n]+"</td>");
- }
-
- }
- writer.println("</tr>");
- }
- //Add html footer
- writer.println("</table></body>\n</html>");
-
- writer.flush();
- writer.close();
- }catch(Exception e){
-
- }
-
-
- }
-
- }
Indlæg senest redigeret d. 09.12.2013 22:24 af Bruger #15663