004-002-004
Array Creation: Temperature Data Management
Easy
Problem Description
Array Creation: Temperature Data Management
Learning Objective: Learn how to manage data using arrays
Create a program that inputs temperatures for 3 days, stores them in an array, and displays the first, last, and count.
Input
Line 1: Day 1 temperature (integer)
Line 2: Day 2 temperature (integer)
Line 3: Day 3 temperature (integer)
Output
First: [day1 temp]
Last: [day3 temp]
Count: [count]
Test Cases
※ Output examples follow programming industry standards
Input:
20 25 22
Expected Output:
First: 20 Last: 22 Count: 3
Input:
15 18 12
Expected Output:
First: 15 Last: 12 Count: 3
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
›
⌄
⌄
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// temperatures と 格納 で 配列を入力
int[] temps = new int[3];
temps[0] = sc.nextInt();
temps[1] = sc.nextInt();
temps[2] = sc.nextInt();
// 最初 と 最後 temperaturesを表示
System.out.println("First: " + temps[0]);
System.out.println("Last: " + temps[2]);
// の配列の長さ (要素 カウント)を表示
System.out.println("Count: " + temps.length);
}
}
0 B / 5 MB
You have 10 free executions remaining
