Question:
Javascript help!!?
lilredthetease
2006-09-19 16:40:59 UTC
This is my HW assignment. I'm not asking anyone to DO it for me I don't even understand what the hell I am supposed to do. Maybe someone can break it down for me? LOL

Question states:
A mail order house sells five different products whose retail prices are: product 1- $2.98, product 2 $4.50, product 3- $9.98, product 4- $4.49, and product 5- $6.87. Write a script that reads a series of pairs of numbers as follows:

a) Product Number
b) Quantity sold for one day

Your program should use a switch structure to help determine the retail price for each product. Your program should calculate and output HTML that displays the total retail value of all products sold last week. Use a prompt dialog to obtain the product number from the user. Use a sentinel-controlled loop to determine when the program should stop looping and display the final results.
Five answers:
jtrelfa
2006-09-19 18:52:55 UTC
I'll break it down rather than solve it. Maybe it will help:



A switch structure is like a big long if, else if, else if, else if statement

Instead of this:



if (test condition) {

//do stuff

} else if (test condition2) {

//do stuff

} else if (test condition 3) {

//do stuff

... etc



You can do it like this:



switch (valueCheck) {

case "value1":

//do stuff

break;

case "value 2":

//do stuff

break;

default:

//do stuff

break;

}



The prompt dialog is a way to get user input using JavaScript. Whatever the user enters is what is returned to your function:



var prodNumber = prompt("Enter a product number");



the 'prodNumber' variable will now hold whatever the user typed in.



A sentinel controlled loop will loop through a set of code until the value of the 'sentinel' is reached. This would be one of those things like:



while (userInput != "") {

prodNumber = prompt("Enter product number, leave blank when done");

}

That loop will continue until the user leaves the prompt blank.



I'll leave the rest of the code up to you. Keep in mind that you're going to need to store the user-entered data and perform calculations. Your prices should be a series of name value pairs or an array of javascript objects



Email me if you need more help jtrelfa_at_yahoo.com
?
2017-01-20 06:19:35 UTC
1
2016-10-17 11:21:14 UTC
you're taking a kind and you are able to desire to study Javascript? Then do no longer ask for a whole answer. Your instructor will in all probability be waiting to tell beginner code from expert code. All you are able to desire to do is study the thank you to place in writing a loop and use an "if" assertion with a modulus operator.
Alex V
2006-09-19 17:23:50 UTC
Here, I hope this is what you were looking for:



girish4music
2006-09-19 16:42:52 UTC
JavaScript Source: Free JavaScripts, Tutorials, Example Code ...The JavaScript Source is your resource for thousands of free JavaScripts for cutting and pasting into your Web ... JavaScript Help · Contribute a script ...

javascript.internet.com/ - 54k - 18 Sep 2006 - Cached - Similar pages



Navigation - javascript.internet.com/navigation/

Forms - javascript.internet.com/forms/

internet.com - the Internet and ... - www.internet.com/

Miscellaneous - javascript.internet.com/miscellaneous/

More results from javascript.internet.com »


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...