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

Thread: Homework Help

  1. #1
    New to the CF scene
    Join Date
    Nov 2012
    Thanked 0 Times in 0 Posts

    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.
    		<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>											
    								<br />
    								<input type="submit" value="Submit" />
    								<input type="reset" value="Clear" />
    and for the javascript file which it feeds into:

    			// 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 + "" + + "");
    Last edited by Starscream59; Nov 3rd, 2012 at 12:47 AM.


Posting Permissions

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