This is a JSFiddle assignment and must be completed at jsfiddle.net and include
ID: 3574623 • Letter: T
Question
This is a JSFiddle assignment and must be completed at jsfiddle.net and include both the HTML and Java sections
In programming you are often confronted with a choice of choosing the correct object, structure, or algorithm to solve a problem. Making the wrong choice often leads to inefficiencies that must be corrected later or a complete inability to solve the problem. This is important enough that there are even guides to technical interviews that help you get ready for these types of questions ( see http://careerdrill.com/blog/coding-interview/choosing-the-right-data-structure-to-solve-problems/ ).
Also common in programming is the use of Caffeine ( https://en.wikipedia.org/wiki/Caffeine )
So you will get to have a little fun with this assignment. You will model a caffeine molecule as a graph and present that computer model. Edges that are single bonds should be presented with a weight of 1, with a double bond - they should have a weight of 2.
Build your model as a Graph. The graph should be able to print all of its Nodes with each adjacent node. You can have a print button or simply call it when the Graph is built.
Output:
H (C) <- there will be 9 of these
C (N,H) <- there will be 3 of these
N (C, C, C) <- there are 3 of these
N (C, C) <- only one of these
etc....
etc...
for each element and combination of connected element
Explanation / Answer
In javascript, there is a library i.e. CH5M3D library.All of the JavaScript or html code required to use this program is contained in the external library ch5m3d.js. The layout and appearance of this editor is controlled using the ch5m3d.css stylesheet. Typically, both of these files will be stored in the same directory as the HTML web pages and included in the HEAD section of the web page using the following statements.
Many of the CH5M3D library routines need to be run after the page has been read by the browser. This can be accomplished by adding the following line to the < body > statement:
<body>
The HTML code required to create simple web pages is minimal. The most important HTML5 element required to use this program
is the Canvas object, which provides the drawing window for showing the molecule. This element must be given a unique identifier using the “id” tag.
The dimensions of this canvas are set by the HTML declaration, and can be adjusted as desired. While a square canvas is usually preferred, the width
and height are not required to be identical.
<canvas id="molcanvas" width="500" height="500"></canvas>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<link rel="stylesheet" type="text/css" href="ch5m3d.css"/>
<script type="text/javascript" src="ch5m3d.js"></script>
<title>MOLECULAR STRUCTURE</title>
</head>
<body>
<p>
<canvas id="molcanvas" width="500" height="500"/>
</p>
<p>
<input type="button" value="Labels"/>
<input type="button" value="Rotate Y"/>
</p>
<p>
<strong>Load</strong><br>
<input type="file" id="molfile" title="browse"/>
</body>
</html>
By this code,we can see any molecule in 3-d structure and also we can browse any supported file having any molecule to view its structure.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.