Below is the following jsp code for a homework assignment im working on. Im allow four input text fields in which a customer can enter the amount of each fruit they want to buy, a submit button, and a reset button. After a customer placed an order, a page should be generated displaying the order information, including the fruit type, amount to buy, subtotal charge for each type of fruit, and total charge.

<HTML>
<HEAD><TITLE>Fruit Business</TITLE></HEAD>
<BODY>
<H1> Welcome to FarmersMarket</H1>
<BR>

<% String app=request.getParameter("apple");

String bana=request.getParameter("banana");

String gra=request.getParameter("grape");

String orang=request.getParameter("orange");

int num=Integer.parseInt(apple);
int num2=Integer.parseInt(banana);
int num3=Integer.parseInt(grape);
int num4=Integer.parseInt(orange);

%>

Here is your order:<br>

Apple: <%= num%> LB and Subtotal: $<%= num*1%><br>
Banana: <%= num2%> LB and Subtotal: $<%= num2*2%><br>
Grape: <%= num3%> LB and Subtotal: $<%= num3*3%><br>
Orange: <%= num4%> LB and Subtotal: $<%= num4*4%><br>

Total Due: $<%= 1*num+ 2*num2+ num3*3+ num4*4%>

<form action=order.jsp method=post>

Apple <input type=text name=apple>[$1]<br>

Banana <input type=text name=banana>[$2]<br>

Grape <input type=text name=grape>[$3]<br>

Orange <input type=text name=orange>[$4]<br>

<input type=submit>
<input type=reset>

</form>

Im not sure what wrong but i am not able to get it to run. I m getting errors in this part of the code:

int num=Integer.parseInt(apple);
int num2=Integer.parseInt(banana);
int num3=Integer.parseInt(grape);
int num4=Integer.parseInt(orange);

I would suggest that you go to a programming forum and ask for assistance there.

I'm sure you will have more luck. Considering most helpers here are not proficient in programming.

Good Luck!

This is a JSP code for a simple fruit order form. It allows customers to enter the quantity of each fruit they want to purchase and displays the order details and total amount.

To explain the code:

1. The first part is the Java code embedded within the HTML. It retrieves the values entered by the customer in the input fields using the `request.getParameter()` method.

2. The input values are then converted from strings to integers using `Integer.parseInt()`, so they can be used for calculations.

3. Next, the order details are displayed using HTML tags and the `<%= %>` notation is used to print the values of the variables. The subtotal for each fruit is calculated by multiplying the quantity entered with the respective price.

4. The total charge is calculated using the same principle, by adding the subtotal charges for each fruit.

5. Below the order details, there is a form with the action set to `order.jsp` and the method set to `post`. This means that when the customer submits the form, the data will be sent to the `order.jsp` page using the HTTP POST method.

6. The input fields for each fruit type are displayed with their respective names (`apple`, `banana`, `grape`, `orange`). The price of each fruit is displayed next to the input field using square brackets.

7. Finally, there are two buttons: "Submit" and "Reset". The "Submit" button will send the form data to the `order.jsp` page, and the "Reset" button will clear all the input fields.

To make this code work, you need to save it in a `.jsp` file, ex: `order.jsp`, and ensure that your server is configured to run JSP files.

Once the form is submitted, the data can be processed in the `order.jsp` file to store it or perform further actions as needed.