弊社の新人エンジニア研修向けのJSP Servletの問題集です。
問題1 丁半のサイコロゲームを作成したい。丁半では、偶数を丁(ちょう)、奇数を半(はん)と呼ぶ。
ツボ皿に入れて振られた二つのサイコロ(サイ)の出目の和が、丁(偶数)か、半(奇数)かで判定する。
以下のソースコードの続きを埋めなさい。
ソースコード①
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <% int dice1 = (int) (Math.random() * 6) + 1; int dice2 = (int) (Math.random() * 6) + 1; int me = dice1 + dice2; if (me % 2 == 1) { %> <%-- ここに解答を記述する --%> </body> </html> |