/    Sign up×
Community /Pin to ProfileBookmark

How would one go about creating this program?

Hi, I’m very new to java and I’d like to know how to do this:

Design a web document that uses the JavaScript prompt function to ask the user for 6 negative, odd numbers and determine the total of those values. Use a WHILE loop and appropriate IF statement(s) to get these values from the user. If the user enters a valid number add that value to a variable called totalValue; otherwise keep asking for valid numbers. You should display to the screen the 6 valid values entered by the user plus the grand total of the six values.

Thanks,

Loverboy

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@CharlesApr 07.2005 — Well, you're not going to get me to do your homework for you but the people here might guide you through the process. The first step is to have a web page. What do you have so far?
Copy linkTweet thisAlerts:
@UltimaterApr 07.2005 — It's his choice if he wants to cheat. Here:
[code=html]
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript"><!--
var temp1=0,temp2=0,numbers=[],place=["1st","2nd","3rd","4th","5th","6th"],totalValue=0;
while(temp1<6){
temp1++;
temp2=parseFloat(prompt("Enter the "+place[temp1-1]+" odd negitive number",""));
if(isNaN(temp2)){temp1--;continue}
if(temp2>=0){temp1--;continue}
if(temp2%2==0){temp1--;continue}
numbers[numbers.length]=temp2
totalValue+=temp2
}
document.write("<PRE>")
document.write("<b>The six Numbers are:</b>n")
document.write(numbers.join("t"))
document.write("n<b>Their total is</b>n")
document.write(totalValue+"n")
document.write("</PRE>")
//--></SCRIPT>
[/code]
×

Success!

Help @LoverboyDennis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...