CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Java and JSP (http://www.codingforums.com/forumdisplay.php?f=54)
-   -   Homework Help (http://www.codingforums.com/showthread.php?t=280636)

Starscream59 11-03-2012 12:44 AM

Homework Help
 
Hi, I'm kind of panicked, I have a homework assignment due later today, but I have no idea what I need to do. The requirement is to design a form that will prompt customers to enter their names, and to choose whether to rent a full size car, medium size car, or small size car. The form should also prompt users to enter the number of days to rent the car. Add a button (submit) to help send the form’s data to a server-side script and another button (reset) to clear the form’s data.

Accept the form’s data using a JSP file with the following criteria to calculate the total cost of renting the car:

• If a user chooses to rent a full size car, the charge is going to be $54.99 per day.
• If a medium size car is chosen, the charge for it should be $45.99 per day.
• Small size cars cost $36.99 per day to rent.

The following data should also be displayed: customer name, car size, days of renting, cost per day, total cost.


Here is what I have so far, even though I am probably no where close to being on the right track, so any help would be appreciated.
Code:

<html>
        <head>
        </head>
       
        <body>
                <div style="text-align: center">
                        <h2>Car Rental</h2>
                       
                        <form method="post" action="car.jsp">
                        What is your name?  <input type="text" name="pname" size=""/><br />
                        Length of Rental:        <input type="text" name="time" size=""/> <br /> Days
                        Choose:                                <select name="car">
                                                                        <option value="small">Small </option>
                                                                        <option value="medium">Medium</option>
                                                                        <option value="full">Full</option>                                                                                       
                                                                </select>
                       
                                                                <br />
                                                                <input type="submit" value="Submit" />
                                                                <input type="reset" value="Clear" />
                </form>
                </div>
        </body>
       
</html>

and for the javascript file which it feeds into:

Code:

<body>
                <%
                       
                        // Receiving data from the client
                        String size = request.getParameter("car");
                        boolean length= Double.parseDouble(request.getParameter("time"));
                        boolean vehicle= 0.0;
                       
                       
                       
                        //assign the chosen convertion
                        if (size.equals("small"))
                        {
                                vehicle = (car) +  ;
                                out.print(car + "" + + "");
                        }
                        else if (size.equals("medium"))
                        {
                                vehicle = (car) /;
                                out.print(car + "" + + "");
                        }
                        else if (size.equals("full"))
                        {
                                vehicle = (car) /;
                                out.print(car + "" + + "");
                        }
                       
                       
                       
                       
                %>
</body>
</html>



All times are GMT +1. The time now is 08:46 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.