Math class conversion program in JS

This is a currency conversion program created by me, done in JS. During math class, while learning about conversions, we were supposed to use code.org to create a program similar to this one. Although, due to my lack of knowledge of code.org, and my familiarity with JS, I created it in JS instead. Also, this was done by hard coding, although now I probably would have made it flexible, using more general conversions to a single variable then branching it from there. (Ex: (Inaccurate) 1$ CAD=1.2$ USD, 1$USD=10 Yen, Therefore 1$ CAD=1.2×10 Yen, 1$ CAD=12 Yen.)

If it doesn't run, on Google Chrome, right click. Then, click "Inspect". Then press "Console" then copy and paste the code below, and press Enter. (Ignore some of the text changing throughout the pictures.) (Other/better options below.)

The code:

var use=prompt ("This is a currency conversion program. Do you want to use it?
(Only relevant for a specific post.) 1=Yes, 2=No.")
if (use>0&&use<2){
alert ("Currency conversion program based in 2021 May 5th. Currency conversion may not be accurate by the time of use. All info was provided by Google and associated companies. Some information may be inexact. If there is an error, you must restart the program. Only answer as suggested.")
alert ("This has Canadian Dollars (CAD), American Dollars (USD), European Euros (EUR), Japanese Yen (JPY), Chinese Yuan (CNY/RMB?), and British Pounds (GBP) (Also known as Sterling Pounds.)")
var side1=prompt ("What currency are you using? (Type it in the order it was stated:Canadian=1, American=2, Euros=3, Yen=4, Yuan=5, and British Pounds=6.)")
var side2=prompt ("What do you want to convert it into? Same rules apply.(Canadian=1, American=2, Euros=3, Yen=4, Yuan=5, and British Pounds=6)")
var money=prompt ("How much money would you like to convert?")
if (money>99998&&money<100000){
alert ("You are like my brother Noah.")
}else{
if (side1>0&&side1<2){
if (side2>1&&side2<3){
alert (money + " dollars in Canadian is " + (money*0.82) + " in American Dollars.")
}else if (side2>2&&side2<4){
alert (money + " dollars in Canadian is " + (money*0.68) + " in Euros.")
}else if (side2>3&&side2<5){
alert (money + " dollars in Canadian is " + (money*89.12) + " in Yen.")
}else if (side2>4&&side2<6){
alert (money + " dollars in Canadian is " + (money*5.28) + " in Yuan.")
}else if (side2>5&&side2<7){
alert (money + " dollars in Canadian is " + (money*0.59) + " in British Pounds.")
}else if (side2>0&&side2<2){
alert ("It's the same.")
}else {
alert ("Please reread the instructions and follow them.")
}
}else if (side1>1&&side1<3)
if (side2>1&&side2<3){
alert ("It's the same.")
}else if (side2>2&&side2<4){
alert (money + " dollars in American is " + (money*0.83) + " in Euros.")
}else if (side2>3&&side2<5){
alert (money + " dollars in American is " + (money*109.29) + " in Yen.")
}else if (side2>4&&side2<6){
alert (money + " dollars in American is " + (money*6.47) + " in Yuan.")
}else if (side2>5&&side2<7){
alert (money + " dollars in American is " + (money*0.72) + " in British Pounds.")
}else if (side2>0&&side2<2){
alert (money + " dollars in American is " + (money*1.23) + " in Canadian Dollars.")
}else{
alert ("Please reread the instructions and follow them.")
}
else if (side1>2&&side1<4){
if (side2>1&&side2<3){
alert (money + " in Euros is " + (money*1.2) + " in American Dollars.")
}else if (side2>2&&side2<4){
alert ("It's the same.")
}else if (side2>3&&side2<5){
alert (money + " in Euros is " + (money*131.07) + " in Yen.")
}else if (side2>4&&side2<6){
alert (money + " in Euros is " + (money*7.77) + " in Yuan.")
}else if (side2>5&&side2<7){
alert (money + " in Euros is " + (money*0.86) + " in British Pounds.")
}else if (side2>0&&side2<2){
alert (money + " in Euros is " + (money*1.47) + " in Canadian Dollars.")
}else {
alert ("Please reread the instructions and follow them.")
}
}else if (side1>3&&side1<5){
if (side2>1&&side2<3){
alert (money + " in Yuan is " + (money*0.15) + " in American.")
}else if (side2>2&&side2<4){
alert (money + " in Yuan is " + (money*0.13) + " in Euros.")
}else if (side2>3&&side2<5){
alert (money + " in Yuan is " + (money*16.87) + " in Yen.")
}else if (side2>4&&side2<6){
alert ("It's the same.")
}else if (side2>5&&side2<7){
alert (money + " in Euros is " + (money*0.11) + " in British Pounds.")
}else if (side2>0&&side2<2){
alert (money + " in Euros is " + (money*0.19) + " in Canadian.")
}else {
alert ("Please reread the instructions and follow them.")
}
}else if (side1>4&&side1<6){
if (side2>1&&side2<3){
alert (money + " in British Pounds is " + (money*1.39) + " in American.")
}else if (side2>2&&side2<4){
alert (money + " in British Pounds is " + (money*1.16) + " in Euros.")
}else if (side2>3&&side2<5){
alert (money + " in British Pounds is " + (money*151.85) + " in Yen.")
}else if (side2>4&&side2<6){
alert (money + " in British Pounds is " + (money*9) + " in Yuan.")
}else if (side2>5&&side2<7){
alert ("It's the same.")
}else if (side2>0&&side2<2){
alert (money + " in British Pounds is " + (money*1.71) + " in Canadian.")
}else {
alert ("Please reread the instructions and follow them.")
}
}else {
alert ("Please reread the instructions and follow them.")
}
}
}else{
alert ("Okay.")
}

If that doesn't work, use JSFiddle (https://jsfiddle.net/mh3z0fwp/2/), and just use the link. If that doesn't work, in the JS section (bottom left quarter) put in this code (it's different that above, but does the exact same thing. Google counts a paragraph ending as a semicolon, and most JS doesn't work that way) If it doesn't run, you stop it, or you want to activate it again, use the "Run" button at the top left:

var use=prompt ("This is a currency conversion program. Do you want to use it. (Only relevant for a specific post.) 1=Yes, 2=No.")
if (use>0&&use<2){ alert ("Currency conversion program based in 2021 May 5th. Currency conversion may not be accurate by the time of use. All info was provided by Google and associated companies. Some information may be inexact. If there is an error, you must restart the program. Only answer as suggested.");alert ("This has Canadian Dollars (CAD), American Dollars (USD), European Euros (EUR), Japanese Yen (JPY), Chinese Yuan (CNY/RMB?), and British Pounds (GBP) (Also known as Sterling Pounds.)");var side1=prompt ("What currency are you using? (Type it in the order it was stated:Canadian=1, American=2, Euros=3, Yen=4, Yuan=5, and British Pounds=6.)");var side2=prompt ("What do you want to convert it into? Same rules apply.(Canadian=1, American=2, Euros=3, Yen=4, Yuan=5, and British Pounds=6)");var money=prompt ("How much money would you like to convert?");if (money>99998&&money<100000){ alert ("You are like my brother Noah.") }else{ if (side1>0&&side1<2){ if (side2>1&&side2<3){ alert (money + " dollars in Canadian is " + (money*0.82) + " in American Dollars.") }else if (side2>2&&side2<4){ alert (money + " dollars in Canadian is " + (money*0.68) + " in Euros.") }else if (side2>3&&side2<5){ alert (money + " dollars in Canadian is " + (money*89.12) + " in Yen.") }else if (side2>4&&side2<6){ alert (money + " dollars in Canadian is " + (money*5.28) + " in Yuan.") }else if (side2>5&&side2<7){ alert (money + " dollars in Canadian is " + (money*0.59) + " in British Pounds.") }else if (side2>0&&side2<2){ alert ("It's the same.") }else { alert ("Please reread the instructions and follow them.") } }else if (side1>1&&side1<3) if (side2>1&&side2<3){ alert ("It's the same.") }else if (side2>2&&side2<4){ alert (money + " dollars in American is " + (money*0.83) + " in Euros.") }else if (side2>3&&side2<5){ alert (money + " dollars in American is " + (money*109.29) + " in Yen.") }else if (side2>4&&side2<6){ alert (money + " dollars in American is " + (money*6.47) + " in Yuan.") }else if (side2>5&&side2<7){ alert (money + " dollars in American is " + (money*0.72) + " in British Pounds.") }else if (side2>0&&side2<2){ alert (money + " dollars in American is " + (money*1.23) + " in Canadian Dollars.") }else{ alert ("Please reread the instructions and follow them.") } else if (side1>2&&side1<4){ if (side2>1&&side2<3){ alert (money + " in Euros is " + (money*1.2) + " in American Dollars.") }else if (side2>2&&side2<4){ alert ("It's the same.") }else if (side2>3&&side2<5){ alert (money + " in Euros is " + (money*131.07) + " in Yen.") }else if (side2>4&&side2<6){ alert (money + " in Euros is " + (money*7.77) + " in Yuan.") }else if (side2>5&&side2<7){ alert (money + " in Euros is " + (money*0.86) + " in British Pounds.") }else if (side2>0&&side2<2){ alert (money + " in Euros is " + (money*1.47) + " in Canadian Dollars.") }else { alert ("Please reread the instructions and follow them.") } }else if (side1>3&&side1<5){ if (side2>1&&side2<3){ alert (money + " in Yuan is " + (money*0.15) + " in American.") }else if (side2>2&&side2<4){ alert (money + " in Yuan is " + (money*0.13) + " in Euros.") }else if (side2>3&&side2<5){ alert (money + " in Yuan is " + (money*16.87) + " in Yen.") }else if (side2>4&&side2<6){ alert ("It's the same.") }else if (side2>5&&side2<7){ alert (money + " in Euros is " + (money*0.11) + " in British Pounds.") }else if (side2>0&&side2<2){ alert (money + " in Euros is " + (money*0.19) + " in Canadian.") }else { alert ("Please reread the instructions and follow them.") } }else if (side1>4&&side1<6){ if (side2>1&&side2<3){ alert (money + " in British Pounds is " + (money*1.39) + " in American.") }else if (side2>2&&side2<4){ alert (money + " in British Pounds is " + (money*1.16) + " in Euros.") }else if (side2>3&&side2<5){ alert (money + " in British Pounds is " + (money*151.85) + " in Yen.") }else if (side2>4&&side2<6){ alert (money + " in British Pounds is " + (money*9) + " in Yuan.") }else if (side2>5&&side2<7){ alert ("It's the same.") }else if (side2>0&&side2<2){
alert (money + " in British Pounds is " + (money*1.71) + " in Canadian.")
}else {
alert ("Please reread the instructions and follow them.")
}
}else {
alert ("Please reread the instructions and follow them.")
}
}
}else{
alert ("Okay.")
}

JSFiddle

If you have any other problems, you can tell me in the comments of this page.

11 thoughts on “Math class conversion program in JS”

  1. Ezra! Well done! I’m impressed that you worked with what you knew to get a similar result that we were working on in class! I can tell you love coding as much as me!
    If you could create a fun and interesting code that doesn’t already exist, what do you think it could/would do?

    Mrs. Cleveland

    1. Thanks! Also, for my school passion project, I’m working on a text-based game. It will be in a related blog post maybe.

  2. Hey Ezra,
    I loved what you have done with adding the coding! I love the photos and overall great post! However I found it a bit over whelming! Maybe try and make it a little more laid out!
    -Maytal

  3. Hi Ezra,

    Wow! I can tell you have had experience coding. Did you learn how to code for your passion project this year, or have you had previous experience? I tried your currency converter to change Canadian money into American money. I love how the prompts at the top of the page stated that the exchange rates might be off depending on the day you actually use it. Do you think there are times when you might need a currency converter? Would you like to try and make your own app one day? Maybe that could be a passion project for next year.

    Keep on coding!
    Mrs. Bennett
    P.S. Maybe we should have a coding club next year, what do you think?

    1. I had some experience but I mostly learned for my passion project. Yes, there are definitely times when I could need a rough estimate for money. Also, yes, I want to make a game app.

  4. I love this post because I don’t understand half the things in it!

    🙂

    You clearly know what you are doing and talking about and I echo all the other comments. Like the other teachers, I’m interested to know how the school can better support current and future coders? I saw the comments about clubs, but are there other ways the school could help? Once our Makerspace is able to resume its full functioning, we imagine that app/game creation could take place there – what kinds of equipment might we need?

    Keep up the great work!

    1. First of all: thanks! Some PBC circuit boards would be great, and just some wires and stuff as well as some input boards. Anyways, just a dedicated club for coding, preferably Java or JS.

  5. Wow, Ezra! You have completely blown me away!
    I think it’s amazing that you have included so much detail to meet different readers where they are. Some people may come to the blog, see what you’ve done, and be able to offer comments or suggestions based on what they know about coding. Others may come with limited knowledge (like me) and learn something new! Sharing images and the actual code is helpful for anyone who might want to try it out for themselves.

    Similarly to what has been shared above, I think you would be a great ambassador for helping to up our coding game at OJCS! You mentioned PBC circuit boards. Any other suggestions for first steps?

    1. PBC circuit boards are hardware, and would be for learning hardware. But, for learning coding Unity is good, but learning pure coding (without support code like UNITYS PARTICLE SYSTEM) IS A (Sorry had caps lock) bit harder.

Leave a Reply to Ezra Cancel reply

Your email address will not be published. Required fields are marked *