Thread: Homework Help
View Single Post
Old 11-03-2012, 12:44 AM   PM User | #1
Starscream59
New to the CF scene

 
Join Date: Nov 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Starscream59 is an unknown quantity at this point
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>

Last edited by Starscream59; 11-03-2012 at 12:47 AM..
Starscream59 is offline   Reply With Quote