Вопрос задан 23.07.2018 в 05:55. Предмет Информатика. Спрашивает Годилова Диана.

Составить расписание звонков уроков. Пользователь вводит номер уpока, программа выдает время урока.

Используйте оператор множество выбора switch
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Лахцутко Катюша.

Function getTime(lesson)
{
var times = [];
times.push("8.30");
times.push("9.10");
times.push("10.20");
times.push("11.35");
times.push("12.25");
times.push("13.15");
switch (lesson)
{
case 1: return times[0];
case 2: return times[1];
case 3: return times[2];
case 4: return times[3];
case 5: return times[4];
case 6: return times[5];
default: return "Нет урока.";
}
}

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Creating a School Bell Schedule Program

To create a program that provides the time for each lesson based on the input lesson number, we can use a switch statement to handle different cases. Here's a breakdown of the program:

1. Input Lesson Number: - The user will input the lesson number. 2. Using Switch Statement: - We'll use a switch statement to handle different cases for each lesson number and provide the corresponding time for the lesson.

3. Output: - The program will output the time for the specified lesson.

Let's proceed with the implementation using the provided information.

Using Switch Statement for Lesson Time Lookup

```java // Assuming the user input is stored in a variable called lessonNumber int lessonNumber = /* user input */;

// Using a switch statement to handle different cases for lesson numbers switch (lessonNumber) { case 1: System.out.println("Lesson 1: 8:00 - 8:45"); break; case 2: System.out.println("Lesson 2: 8:50 - 9:35"); break; case 3: System.out.println("Lesson 3: 9:40 - 10:25"); break; // Add cases for other lessons as per the schedule default: System.out.println("Invalid lesson number"); } ```

In this example, the program takes the user input for the lesson number and uses a switch statement to match the input with the corresponding lesson time. If the input matches a case, the program outputs the time for that lesson. If the input doesn't match any case, it outputs "Invalid lesson number."

This approach allows for easy lookup of lesson times based on the lesson number provided by the user.

Feel free to modify the code to include the complete schedule based on the provided information.

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос