JavaScript - Need Help Asap
i really dont understand this java problem, i did all i could and i still dont get it plz help me. Its my practice test for tomorrow and i dont get this.
In video games it is often required to be able to determine if two balls have collided. Create a program which accepts the radius and the center (x,y) of each ball and states whether the two balls have collided. Hint: Draw and label all the known information for situations (2) when the balls have collided and when they have not collided. Similar TutorialsHI lads im new javascript learner ,i have been trying to find out what is wrong with my coding it never worked and i cant see the mistake code : var lotto=[]; var myLotto=[]; function isFilled(field) { while (field==null || field.length == 0 || (!isnotNumeric(field))) { alert("The input was not a valid number"); field = parseInt(prompt("Enter your favourite number, please","")); } return field; } function isnotNumeric(num) { if (isNaN(num) || num < 1 || num > 45) { return false; } else { return true; } } function getData(){ var i = 0; while (i<7) { number = Math.floor(Math.ramdom()*45+1); if (!numberFound(lotto,number)) { lotto [i] = number; alert(lotto[i]); i++; } } } function numberFound(testArray,myNumber) { for (x = 0; x<testArray.length;x++) { if (myNumber == testArray[x]) return true; } return false; } function getMyNumbers() { var number = i; for (i = 0; i<5; i++) { myNumbers = parseInt(prompt("Enter in number " + number + ":","")); isFilled(); number=number+1; } } thank you very much <HTML> <HEAD> <TITLE></TITLE> <SCRIPT LANGUAGE="JAVASCRIPT"><!--Hide from old browsers var msgSpace = "--- ---" var beginPos = 0 function doMort() { document.MortCalc.Price.value=" " document.MortCalc.Shares.value=" " document.MortCalc.Dividend.value=" " document.MortCalc.Time.value=" " document.MortCalc.Price.focus() } function Calc(myform) { var mortAmount=document.MortCalc.Price.value var mortAmount=parseInt(mortAmount,10) if (isNaN(mortAmount)) { alert() document.MortCalc.Price.value=" " document.MortCalc.Price.focus() } else { var mortShares=document.MortCalc.Shares.value var mortShares=parseFloat(mortShares) if (isNaN(mortShares)) { alert() document.MortCalc.Shares.value=" " document.MortCalc.Shares.focus() } else { var mortDividend=document.MortCalc.Dividend.value var mortDividend=parseInt(mortDividend,10) if (isNaN(mortDividend)) { alert(") document.MortCalc.Dividend.value=" " document.MortCalc.Dividend.focus() } } } document.MortCalc.Time.value=monthly(mortPrice,mortShares,mortDividend) document.MortCalc.Time.value=dollarFormat(document.MortCalc.Time.value) } function Price(mortPrice,mortShares) { var Price * Shares } function dollarFormat(valuein) { var formatStr="" var Outdollars="" var decipos=valuein.indexOf(".") if (decipos==-1) decipos=valuein.length var dollars=valuein.substring(0,decipos) var dollen=dollars.length if (dollen>3) { while (dollen>0) { tDollars=dollars.substring(dollen-3,dollen) if (tDollars.length==3) { Outdollars=","+tDollars+Outdollars dollen=dollen-3 } else { Outdollars=tDollars+Outdollars dollen=0 } } if (Outdollars.substring(0,1)==",") dollars=Outdollars.substring(1,Outdollars.length) else dollars=Outdollars } var cents=valuein.substring(decipos+1,decipos+3) if (cents=="") cents="00" var formatStr="$"+dollars+"."+cents return formatStr } open("Notice.htm","noticeWin","WIDTH=400,HEIGHT=220") (edit) i've fixed it. thanks
this is what i have so far but im having trouble adding an accessor method for answer which i have called getAnswer public class Question { private String text; private String answer; private String getAnswer; /** * Constructs a question with empty question and answer. */ public Question() { text = ""; answer = ""; } /** * Sets the question text. * @param questionText the text of this question */ public void setText(String questionText) { text = questionText; } /** * Sets the answer for this question. * @param correctResponse the answer */ public void setAnswer(String correctResponse) { answer = correctResponse; } public String getAnswer(){ return answer; } /** * Checks a given response for correctness. * @param response the response to check * @return true if the response was correct, false otherwise */ public boolean checkAnswer(String response) { return response.equals(answer); } /** * Displays this question. */ public void display() { System.out.println(text); } } Hi i need some help for my validation, it does not have pop up for the words that match with bw and my codes i need to check whether is it a ew. if it is a ew even if it contain bw it will return true. hope there is someone can help me thanks alot in advance my codes are this var sw = theForm.fmessage.value.split(" "); var tw = theForm.fmessage.length; var i=0; for (i=0;i<tw;i++){ <?php while($row1 = mysql_fetch_assoc($result1)){?> var ew = "<?php echo $row1['ew'] ; ?>"; var bw = "<?php echo $row1['bw'] ; ?>"; if (sw[i].match(bw)) { alert(bw); err = bw; } <?php }?> } if (err != "") { alert("Badword(s) found : " + err); theForm.fmessage.focus(); return false; } hey guys can u please help me with this question.. i've lost ma book and its too late to buy another one.. so some body please help me! this is the question: Kathryn bought 600 shares of stock at a price of $21.77 per share. She must pay her stockbroker a 2 percent commission for the transaction. Write a program that calculates and displays the following: The number of shares purchased The price per share The amount paid for the stock alone (without the commission) (number of shares x share price) The amount of the commission (amount paid for the stock x the commission percent) The total amount paid (for the stock plus the commission) (amount paid for the stock + the amount of the commission) The program should neatly display a text label along with the value. For example: Shares purchased: 600 The program must perform the calculations. It is not acceptable to perform the calculations on a calculator and just use the program to display the results. I should be able to modify the numbers in the program and have it correctly compute the result. Hi, i need to make my alert box stand out a bit more i have looked everywhere but can't find anything! i was looking to do stuff like Bold, Italics, Underline, Fonts, Sizes, Borders, Backgrounds maybe something that flashed! i'm not asking you to do it for me just tell me how and were to put the different codes! and ASAP please as it is in for Thursday!! :S thanks in advance :D Hey, basically I have my assignment due in 2 and a half hours and I cannot work out how to validate a email address. What am I doing wrong? Been on the net for a couple of hours lurking to find some answers but now I am even more lost. Bit of information: Basically I need to work out how many tables are needed for a class room depending on the desktops and laptops used and how many roils of coils are needed blah blah blah. Then comes the tricky part (for me anyways) asking the user to confirm or cancel the order everything works up to confirming the quote and then validating the email address, canceling the confirm button works so I'm assuming it's just the validating that I have destroyed. Any help would be awesome, assignment is due very soon and no sections of code are helping me on the net. Code: function confirmquote() { var answer=confirm("Do you want to recieve a quote?"); if (answer==true) { var emailID=window.prompt("Please enter a VALID email address or type quit to exit"); } else { alert("Quote has been rejected sir, please refreash to start order agian."); } } } function CheckEmail() { emailID = document.f1.Email.value AtPos = emailID.indexOf("@") StopPos = emailID.lastIndexOf(".") Message = "" if (emailID == "") { Message = "Not a valid Email address" + "\n" } if (AtPos == -1 || StopPos == -1) { Message = "Not a valid email address" } if (StopPos < AtPos) { Message = "Not a valid email address" } if (StopPos - AtPos == 1) { Message = "Not a valid email address" } return Message } (ALL IN THE HEADER TAG) Code: var worknowplease = confirmquote(); var emailID=checkemail(); (Last few lines of code before [/body]) I have no idea what the validate email is trying to do in the coding, but I'm still very freash on JS. Thanks you for reading and if you can share any possible solutions to my problems. Thanks agian. |