score.html
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
<style>
fieldset {
width: 600px;
}
table {
margin: 0px auto;
text-align : center;
}
</style>
</head>
<body>
<form action="score.jsp" method="post">
<fieldset>
<legend>학점확인프로그램</legend>
<table>
<tr>
<td>이름</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>JAVA점수</td>
<td><input type="text" name="java"></td>
</tr>
<tr>
<td>WEB점수</td>
<td><input type="text" name="web"></td>
</tr>
<tr>
<td>IOT점수</td>
<td><input type="text" name="iot"></td>
</tr>
<tr>
<td>ANDROID점수</td>
<td><input type="text" name="android"></td>
<tr>
<td colspan=2><input type="submit" value="확인하기"></td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>
score.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
<style>
fieldset {
width: 400px;
}
table {
width: 200px;
margin: 0px auto;
}
</style>
</head>
<body>
<%
request.setCharacterEncoding("EUC-KR");
String name = request.getParameter("name");
String java = request.getParameter("java");
int mdJava = Integer.parseInt(java);
String web = request.getParameter("web");
int mdWeb = Integer.parseInt(web);
String iot = request.getParameter("iot");
int mdIot = Integer.parseInt(iot);
String android = request.getParameter("android");
int mdAndroid = Integer.parseInt(android);
double avg = 0;
avg = ((int) ((mdJava + mdWeb + mdIot + mdAndroid) / 4) * 100) / 100;
String score = "";
if (avg <= 100 && avg >= 95) {
score = "A+";
} else if (avg >= 85) {
score = "A";
} else if (avg >= 80) {
score = "B+";
} else if (avg >= 70) {
score = "C";
} else {
score = "F";
}
%>
<fieldset>
<legend>학점확인프로그램</legend>
<table>
<tr>
<td>이름</td>
<td><%=name%></td>
</tr>
<tr>
<td>JAVA점수</td>
<td><%=java%></td>
</tr>
<tr>
<td>WEB점수</td>
<td><%=web%></td>
</tr>
<tr>
<td>IOT점수</td>
<td><%=iot%></td>
</tr>
<tr>
<td>ANDROID점수</td>
<td><%=android%></td>
</tr>
<tr>
<td>평균</td>
<td><%=avg%></td>
</tr>
<tr>
<td>학점</td>
<td><%=score%></td>
</tr>
</table>
</fieldset>
</body>
</html>
'Programming > Servlet & JSP' 카테고리의 다른 글
멤버 관리 (jsp, servlet, 로그인, 회원 가입, 정보 관리) (0) | 2020.02.19 |
---|---|
footer 만들기, 꼬리 번호 (0) | 2020.02.19 |
오류페이지 화면 (오류 메세지 가리기) (0) | 2020.02.19 |
숫자를 html로 입력받고 구분하여 사진을 servlet에서 보여주기(div, pNum, if, img) (0) | 2020.02.19 |
URL Mapping (url 맵핑) (0) | 2020.02.19 |