459,730 Members | 1,620 Online
Need help? Post your question and get tips & solutions from a community of 459,730 IT Pros & Developers. It's quick & easy.

# Assignment on Javascript

 P: 1 This is homework due soon, and I am lost. Due in a few hours. I'm stuck, and looking for how to do this. Any suggestions? This time the numbers that you are converting range from zero to one-hundred thousand. ...[snipped] As with Project 7, you are to write an HTML page, complete with a header, title and a body containing a JavaScript script. The general page describes the behavior of the script. The script first prompts the user for an integer number between 0 and 100,000. Next, the script checks that the user entered a number within the specified range and generated the English name for that number. For instance, if the user entered the number "67,231", the script would generate the name "sixty-seven thousand two hundred and thirty-one". The generated name is inserted in the page, toward the bottom, with an appropriate explanation. [snipped] Nov 21 '07 #1
10 Replies

 100+ P: 1,137 Sorry we are not aloud to help you on homework assignments, please refer to the Posting Guidelines . Thanks, Death Nov 21 '07 #2

 100+ P: 210 Sorry we are not aloud to help you on homework assignments. Is it O.K. to help people quietly? Nov 22 '07 #3

 100+ P: 428 Here is one for Roman numerals. Just rearrange it a bit for your homework. : Expand|Select|Wrap|Line Numbers function check_romandec(){     String.prototype.fromRoman= function(){                 var num= '', sum= 0, tem;         var rGA= [['DCCCC','CM'],['LXXXX','XC'],['VIIII','IX'],['CCCC','CD'],['XXXX','XL'],['IIII','IV']];         if(/\D/.test(this)==false){             num= Number(this).toRoman();             for(var i= 0; i<6; i++) num= num.replace(rGA[i][0],rGA[i][1]);             return num;         }         else{             var rX= / [^IVXLCDM]/;             num= this.toUpperCase();             if(rX.test(num)) return '';             for(var i= 0;i<6;i++)num= num.replace(rGA[i][1],rGA[i][0]);             var rN= {I:1, V:5, X:10, L:50,C:100, D:500, M:1000};             var rNA= num.split('');             var nA= new Array;             for(var i= 0; i= 0;i--){             if(n> aN[i]){                 tem= Math.floor(n/aN[i]);                 while(tem>0){                     num+= rN[i];                     tem--;                 }                 n= n%aN[i];             }         }         return num;     }     return true; } Math.floor(n/aN[i]) is sure to impress your instructor. Nov 22 '07 #4

 Expert Mod 15k+ P: 16,027 nchgoguy, The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve. Please read the Posting Guidelines and particularly the Coursework Posting Guidelines. Then when you are ready post a new question in this thread. MODERATOR Nov 22 '07 #5

 Expert Mod 15k+ P: 16,027 Math.floor(n/aN[i]) is sure to impress your instructor. Not if he can't explain what it does! :) Nov 22 '07 #6

 Expert Mod 15k+ P: 16,027 Is it O.K. to help people quietly? Ooh, that's nasty(!) - a nice pun though! Nov 22 '07 #7

 100+ P: 1,137 Is it O.K. to help people quietly? I personaly believe that's ok as long as you explain the code making it a learning experience. - Death Nov 23 '07 #8

 100+ P: 1,137 Not if he can't explain what it does! :) What does it do exactly? Nov 23 '07 #9

 Expert Mod 15k+ P: 16,027 What does it do exactly? It divides the number by the current decimal and returns an integer (by 'flooring' the result). For example, if the number was 5050, Math.floor(n/aN[i]) would give Math.floor(5050/1000) which equals 5. This allows the while loop to get 5 Ms. Nov 26 '07 #10

 100+ P: 1,137 It divides the number by the current decimal and returns an integer (by 'flooring' the result). For example, if the number was 5050, Math.floor(n/aN[i]) would give Math.floor(5050/1000) which equals 5. This allows the while loop to get 5 Ms. Nice - Death Nov 26 '07 #11