Click to See Complete Forum and Search --> : if and else statements
josh_javascript
11-17-2003, 08:32 PM
Anyone have any advice on how to create the following program in JavaScript using if and else statements:
A copy center charges 5 cents per copy for the first 100 copies and 3 cents per copy for each additional copy.
Basically a prompt box would request the number of copies and then it would be calculated. For instance, 125 copies would come out to 5.75.
Sounds like homework - is it?
96turnerri
11-18-2003, 03:12 AM
you want help/advice on if else id try
if (value =< '100) {
document.write("$"(value * 5));
} else {
document.write("$"((value - 100) * 3) + 500);
}
try modding that or something
fredmv
11-18-2003, 04:19 AM
Originally posted by pyro
Sounds like homework - is it? Sounds like it to me. Why don't you try something on your own first before asking for answers? I'd help you, but I wouldn't want to break any rules on this forum for giving out answers to homework assignments.
josh_javascript
11-18-2003, 09:32 AM
Sorry, I should have been more specific regarding what it was I was looking for help with. Basically, I understand the concept of if and else statements. The part I couldn't figure out is how to write the script so that the first 100 copies go for 5 cents per copy and then anything beyond that is 3 cents per copy.
The best I could get it was so that anything <= to 100 was five cents per copy or anything >= to 101 was three cents per copy. I simply couldn't figure out how to make it so that anything beyond 100 copies is 3 cents per copy, instead of the entire amount being 3 cents per copy. Not sure if that makes any sense or not. I'll be more specific next time.
96turnerri
11-18-2003, 09:36 AM
take you original script and replace these if else statements to your script see if that works, if it doesnt post your script as you have it on here
96