Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function execCode() {
- heading();
- year();
- }
- function heading() {
- println(" Amount Amount");
- println(" Simple Compound");
- println("Year Interest Interest");
- }
- function year() {
- for (var i = 1; i < 10; i++) {
- var yr = i;
- var smpl = 1000+(50*i);
- print(yr);
- print(" ");
- print("$"+smpl+".00");
- print(" ");
- switch (i) {
- case 1:
- var a = 1000*1.05;
- println(a);
- break;
- case 2:
- var b = newRound(a*1.05,2);
- println(b);
- break;
- case 3:
- var c = newRound(b*1.05,2);
- println(c);
- break;
- case 4:
- var d = newRound(c*1.05,2);
- println(d);
- break;
- case 5:
- var e = newRound(d*1.05,2);
- println(e);
- break;
- case 6:
- var f = newRound(e*1.05,2);
- println(f);
- break;
- case 7:
- var g = newRound(f*1.05,2);
- println(g);
- break;
- case 8:
- var h = newRound(g*1.05,2);
- println(h);
- break;
- case 9:
- var j = newRound(h*1.05,2);
- println(j);
- break;
- }
- }
- }
- // Return the HTML element named 'id'
- function getElement(id) {
- return document.getElementById(id);
- }
- // Return the text in the 'Input:' box
- function getInput() {
- var input = getElement("input");
- return input.value;
- }
- // Print to the 'output' HTML element
- function print(x) {
- var out = getElement("output");
- out.value = out.value + x;
- }
- // Clear the 'output' text area
- function clr() {
- //alert("hey");
- var out = getElement("output");
- out.value = "";
- }
- // Print to the 'output' HTML element and
- // add the line end
- function println(x) {
- if (x === undefined) {
- x = "";
- }
- print(x + '\n');
- }
- // Sample using the canvas to draw on
- function drawExample() {
- var c;
- var cx;
- c = getElement("drawing");
- cx = c.getContext("2d");
- //cx.strokeStyle = "red";
- cx.lineWidth = 1;
- // draw rect with narrow lines
- cx.strokeRect(5, 5, 100, 50);
- // draw rect with wider lines
- cx.strokeStyle = "red";
- cx.lineWidth = 5;
- cx.strokeRect(135, 5, 50, 50);
- }
- // User defined round function
- // Pass in the number and the number of
- // decimal places to retain
- function newRound(num, places) {
- tens = Math.pow(10, places);
- var temp = num * tens;
- temp = Math.round(temp);
- temp = temp / tens;
- return temp;
- }
- // Put code here to execute when the user
- // presses the 'Run Program' button
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement