Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Java Prompts

  1. #1
    New to the CF scene
    Join Date
    Apr 2014
    Location
    Alto, GA
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Java Prompts

    I have a javascript assignment, and in all honesty, I'm clueless on how to set this up. Can anyone help? And thank you so much in advance!

    Here are the instructions:

    - request the flavor from the user. Flavor choices are: cherry,
    lime, watermelon, grape and orange.
    - If one of these flavors is entered, request the size from the
    user. Size may be small or large.
    - If another flavor is entered, alert the user that the flavor is
    not available.
    - Output the cost to the user: $2 for small and $3 for large. No
    cost should be output if the flavor was not available.
    Add a while loop so that after an order is taken or an invalid
    flavor is entered you prompt the user – “Would you like to
    order another shave ice? (y/n)”.
    - Continue to take orders until the user does not enter y to that
    prompt.
    - When the user does not enter y, output the total cost of the
    orders taken. ($3 for each large and $2 for each small)

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    If your question is about JavaScript why does the title say Java (a completely different language)?

    If you are asking about prompt() (antiquated code for Netscape browsers) why did you post in the DOM and JSON forum?

    Modern scripts use a form in the page itself to get user input. You then attach an event listener to the submit event on the form to call the processing to process the form input and use DOM calls to output the result into the page.

    Also while these forums provide assistance in fixing problems with your code if what you have written doesn't quite work. If you have no idea of where to start with this assignment then it is best to ask your "Early History of JavaScript" teacher for the initial assistance. If we don't know whether the teacher is looking for code the way JavaScript used to be written 15 years ago or the completely different way it used to be written 10 years ago (just before prompt was repurposed for debugging only) then we wouldn't know what sort of historical code is expected for the answer.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,290
    Thanks
    23
    Thanked 611 Times in 610 Posts
    Start with a <select> and <option>s dropdown and use onchange or a listener.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •