Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tanda1;
- import java.io.File;
- import java.io.FileWriter;
- import java.io.IOException;
- import org.jdom2.Document;
- import org.jdom2.Element;
- import org.jdom2.output.Format;
- import org.jdom2.output.XMLOutputter;
- public class Ej1TablaMultiplicar {
- public static void main(String[] args) throws IOException {
- System.out.println("Introduce numero para multiplicar");
- int num=Consola.leeInt();
- Element raiz=new Element("tabla");
- Document doc=new Document(raiz);
- Element factr;
- int mult=1;
- for(int i=1;i<=10;i++)
- {
- mult = num*i;
- factr=new Element("Factor");
- raiz.addContent(new Element("Fact").setText(String.valueOf(i)));
- raiz.addContent(new Element("RSTD").setText(String.valueOf(mult)));
- }
- XMLOutputter salida=new XMLOutputter(Format.getPrettyFormat());
- FileWriter fx=new FileWriter(new File("mult.xml"));
- salida.output(doc,fx);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment