ChaosDecides

Members
  • Content count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About ChaosDecides

  • Rank
    Newbie
  1. I went through and indented everything but I'm still not seeing the problem. I cut and pasted it from eclipse and it messed up the indentation. The original looks a lot better. I added the output for percentage and it works also. Looks like a case of hiding in plain site. My arch nemesis.
  2. Thanks for pointing that out! Fixed. The output part at the end is where I think the issue is happening. Basically once the while statement is no longer true I need the output. I don't know if the loop is checking that last if statement on each pass through. When I just do the come out roll and either win or crap out it works fine. I put in a print function for each line to see that numbers were indeed being generated. However some results just didn't look right. I'd get all 7's once followed by all 11's, then I'd have several in a row with a pretty wide range of rolls.
  3. I'm currently working on a basic craps simulator that needs to ouput the total wins and losses based on x number of interations, as well as output a win percentage. I haven't added the percentage part yet. I'm running it in eclipse and sometimes I'll get the output I want and other times I'll get no output at all. This is the code I've written so far: public class craps { public static void main(String[] args) { int dieOne = (int)(Math.random()* 6) + 1; int dieTwo = (int)(Math.random()* 6) + 1; int roll = dieOne + dieTwo; int winCount = 0; int lossCount = 0; while (winCount + lossCount < 100) if (roll == 2 || roll == 3 || roll == 12){ lossCount++; } else if (roll == 7 || roll == 11){ winCount++; } else { dieOne = (int)(Math.random()* 6) + 1; dieTwo = (int)(Math.random()* 6) + 1; int roll2 = dieOne + dieTwo; while (roll2 != 7){ if(roll == roll2){ winCount++; break; } else { dieOne = (int)(Math.random()* 6) + 1; dieTwo = (int)(Math.random()* 6) + 1; roll2 = dieOne + dieTwo; } if (roll2 == 7){ lossCount++; } if (winCount + lossCount == 100){ System.out.println("Wins: " + winCount); System.out.println("Losses: " + lossCount); } } } }} I'm not seeing what part of the code might return zero ouput, unless eclipse is to blame. The second while loop is supposed to be if you roll a point and are rolling until you make the point or crap out. I'd appreciate any advice. Thanks.
  4. I'm having a hard time dealing with footnotes as well as figuring out how to apply a unit and a source attribute to the table I've created. I need to take the data from the XML file and convert it to HTML to duplicate the html file I've attached. The unit attribute is applied to the area column in the table and the source attribute is an image that is applied to the map table. Since I can't upload the XSL file for some reason, I'll put the code in the post. I've looked through the HTML code to try and get a few clues, but I'm completely stumped. I'll also bold a section that stopped working all of a sudden. <?xml version="1.0" encoding="utf-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" omit-xml-declaration="yes" encoding="utf-8" indent="yes" doctype-system="about:legacy-compat" /> <xsl:template match="/"> <html> <head> <title>Washington Counties</title> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="counties"> <h1>Washington Counties</h1> <p> <a href="{./@source}"> Source </a> </p> <table border="1" style="border-collapse:collapse;"> <tr> <th>County</th> <th>INCITS</th> <th>County Seat</th> <th>Established</th> <th>Origin</th> <th>Etymology</th> <th>Population</th> <th>Area</th> <th>Map</th> </tr> <xsl:for-each select="county"> <xsl:sort select="established" data-type="text" /> <tr> <td id="{@county}"> <a href="{name/@href}"> <xsl:value-of select="name" /> </a> </td> <td id="{@county}"> <a href="{incits/@href}"> <xsl:value-of select="incits" /> </a> </td> <td id="{@county}"> <a href="{countySeat/@href}" > <xsl:value-of select="countySeat" /> </a> </td> <td> <xsl:value-of select="established"/> </td> <td> <xsl:value-of select="origin"/> </td> <td id="{@county}"> <a href="{etymology/@href}" > <xsl:copy-of select="etymology" /> </a> </td> <td> <xsl:value-of select="population"/> </td> <td> <xsl:value-of select="area"/> </td> <td id="{county}"> <a img="{map/@img}"> <xsl:copy-of select="map"/> </a> </td> </tr> </xsl:for-each> </table> <h4>Footnotes</h4> </xsl:template> </xsl:stylesheet> WashingtonCounties.html WashingtonCounties.xml