Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I keep on getting errors on these codes. the following are coded and runned in n

ID: 3604304 • Letter: I

Question

I keep on getting errors on these codes.

the following are coded and runned in netbeans

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@include file="header.jsp" %>
<section>
<h1>Future Value Calculator</h1>
<p><i>${message}</i></p>
<form action="calculate" method="post">
<label>Investment Amount:</label>
<c:if test="${investment != null}">
<input type="text" name="investment"
value="${investment}"/><br>
</c:if>
<c:if test="${investment == null}">
<input type="text" name="investment"
value="${calculation.monthlyInvestmentAmount}"/><br>
</c:if>   
<label>Yearly Interest Rate:</label>
<c:if test="${interestRate != null}">
<input type="text" name="interest_rate"
value="${interestRate}"/><br>
</c:if>
<c:if test="${interestRate == null}">
<input type="text" name="interest_rate"
value="${calculation.yearlyInterestRate}"/><br>
</c:if>
<label>Number of Years:</label>
<input type="text" name="years"
value="${calculation.years}"/><br>

<label>&nbsp;</label>
<input type="submit" value="Calculate"/><br>
</form>
</section>
<%@include file="footer.jsp" %>

1. change the above code so it uses the JSTL choose tags instead of JSTL if tags.

for code below, change the code it so it presents a table that displays the value of the investment for each year up to the year the user entered. To do this, you can use a JSTL forEach tag.

<%@include file="header.jsp" %>
<section>
<h1>Future Value Calculator</h1>

<label>Investment Amount:</label>
<span>${calculation.monthlyInvestmentAmountCurrencyFormat}</span><br />

<label>Yearly Interest Rate:</label>
<span>${calculation.yearlyInterestRate}</span><br />

<label>Number of Years:</label>
<span>${calculation.years}</span><br />

<label>Future Value:</label>
<span>${calculation.futureValueCurrencyFormat}</span><br />

<label>&nbsp;</label>
<span><a href="index.jsp">Return to Calculator</a></span>
</section>
<%@include file="footer.jsp" %>

Explanation / Answer

Hii.. I have changed c:if to c:choose. Please check once.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<section>

<h1>Future Value Calculator</h1>

<p><i>${message}</i></p>

<form action="calculate" method="post">

<label>Investment Amount:</label>

  

<c:choose>

<c:when test = "${investment != null}">

<input type="text" name="investment"

value="${investment}"/><br>

</c:when>

<c:when test = "${investment == null}">

<input type="text" name="investment"

value="${calculation.monthlyInvestmentAmount}"/><br>

</c:when>

</c:choose>

<label>Yearly Interest Rate:</label>

  

<c:choose>

<c:when test = "${interestRate != null}">

<input type="text" name="interest_rate"

value="${interestRate}"/><br>

</c:when>

<c:when test = "${interestRate == null}">

<input type="text" name="interest_rate"

value="${calculation.yearlyInterestRate}"/><br>

</c:when>

</c:choose>

  

<label>Number of Years:</label>

<input type="text" name="years"

value="${calculation.years}"/><br>

<label>&nbsp;</label>

<input type="submit" value="Calculate"/><br>

</form>

</section>

for the secpnd one i have written foreach in jstl with start year of present year and end year is calculated as present year+number of years. I have looped the code and display in table. Please check below. if any thing is wrong comment here. dont give me negative rating. Please check below code.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<section>

<h1>Future Value Calculator</h1>

<jsp:useBean id="now" class="java.util.Date" />

<fmt:formatDate var="year" value="${now}" pattern="yyyy" />

<table border="1">

<tr>

<th>Investment Amount</th>

<th>Yearly Interest Rate</th>

<th>Current Year</th>

<th>Future Value</th>

</tr>

<c:forEach var = "i" begin = "${year }" end = "${year + calculation.years }">

<tr>

<td>${calculation.monthlyInvestmentAmountCurrencyFormat}</td>

<td>${calculation.yearlyInterestRate}</td>

<td>${i}</td>

<td>${calculation.futureValueCurrencyFormat}</td>

</tr>

</c:forEach>

</table>

  

<label>&nbsp;</label>

<span><a href="index.jsp">Return to Calculator</a></span>

</section>

Thanks in advance. All the best. if anything wrong comment here.