Advertisement
stamen4o

Draw House HTML

May 17th, 2014
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.40 KB | None | 0 0
  1. //if it is not working please set the file and folder permissions to full.
  2.  
  3. import java.io.BufferedWriter;
  4. import java.io.File;
  5. import java.io.FileWriter;
  6. import java.util.Scanner;
  7. public class Problem10 {
  8.  
  9.     public static void main(String args[])
  10.     {
  11.         Scanner input = new Scanner(System.in);
  12.         FileWriter fWriter = null;
  13.         BufferedWriter writer = null;
  14.         FileWriter styleWriter = null;
  15.         BufferedWriter cssWriter = null;
  16.         System.out.println("Please enter roof's width here: ");
  17.         double roofWidth = input.nextDouble();
  18.         System.out.println("Please enter body of the house width: ");
  19.         double bodyWidth = input.nextDouble();
  20.         System.out.println("Please enter body of the house height: ");
  21.         double bodyHeight = input.nextDouble();
  22.         try {
  23.             File htmlFile = new File("C:/dok/file.html");
  24.             File cssFile = new File("C:/dok/stylesheet.css");
  25.             fWriter = new FileWriter(htmlFile);
  26.             styleWriter = new FileWriter(cssFile);
  27.             writer = new BufferedWriter(fWriter);
  28.             cssWriter = new BufferedWriter(styleWriter);
  29.             cssWriter.write(
  30.                     ".arrow-up {\n"+
  31.                         "width: 0;\n"+
  32.                         "height: 0;\n"+
  33.                         "margin-left:20%;\n"+
  34.                         "margin-top:250px;\n"+
  35.                         "border-left: " + roofWidth + " solid transparent;\n"+
  36.                         "border-right: " + roofWidth + " solid transparent;\n"+
  37.                         "border-bottom: " + (roofWidth/1.5) + " solid black;\n"+
  38.                     "}\n"+
  39.  
  40.                     ".bodyHouse {\n"+
  41.                         "width: " + bodyWidth + ";\n"+
  42.                         "height: " + bodyHeight + ";\n"+
  43.                         "margin-left:25%;\n"+
  44.                         "margin-top:3;\n"+
  45.                         "background-color:black;\n"+
  46.                        
  47.                     "}\n"+
  48.  
  49.                     ".sun {\n"+
  50.                         "border-radius: 50%;\n"+
  51.                         "width: 100px;\n"+
  52.                         "height: 100px; \n"+
  53.                         "margin-left:70%;\n"+
  54.                         "margin-top:10%;\n"+
  55.                         "background-color:yellow;\n"+
  56.                     "}\n"+
  57.  
  58.                     ".grass {\n"+
  59.                         "width: 1024;\n "+
  60.                         "height: 70; \n"+
  61.                         "background-color:green;\n"+
  62.                         "margin-top:0;\n"+
  63.                     "}"
  64.                     );
  65.             cssWriter.close();
  66.             writer.write("Software University</b>");
  67.             writer.write("</body></html>");
  68.             writer.write("<html><head><LINK href=\"stylesheet.css\" rel=\"stylesheet\" type=\"text/css\"></head><body>");
  69.             writer.write(
  70.                     "<div class=\"sun\"></div>\n"+
  71.                     "<div class=\"arrow-up\"></div>\n"+
  72.                     "<div class=\"bodyHouse\"></div>\n"+
  73.                     "<div class=\"grass\"></div>\n"
  74.                     );
  75.             writer.close();
  76.         } catch (Exception e) {
  77.             e.printStackTrace();
  78.         }
  79.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement