Generation

generate functionSun, 23 Apr 2023

標準入力から整数を入力し、偶数が入力されるまで繰り返し入力を要求するプログラムを作成せよ。

import java.io.*; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; while ((line = br.readLine()) != null) { int count = Integer.parseInt(line); if ((count % 2) == 0) { break; } System.out.println(count + " is odd number"); } } }

Want to kickstart your project?Use the new AI Studio to create your code