Created
December 24, 2014 23:51
-
-
Save roma-sck/caf99e11ebf5e277bb4b to your computer and use it in GitHub Desktop.
test.level05.lesson12.bonus02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level05.lesson12.bonus02; | |
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
/* Нужно добавить в программу новую функциональность | |
Задача: Программа вводит два числа с клавиатуры и выводит минимальное из них на экран. | |
Новая задача: Программа вводит пять чисел с клавиатуры и выводит минимальное из них на экран. | |
*/ | |
public class Solution | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); | |
int a = Integer.parseInt(reader.readLine()); | |
int b = Integer.parseInt(reader.readLine()); | |
int c = Integer.parseInt(reader.readLine()); | |
int d = Integer.parseInt(reader.readLine()); | |
int e = Integer.parseInt(reader.readLine()); | |
int minimum = min(a, b, c, d, e); | |
System.out.println("Minimum = " + minimum); | |
} | |
public static int min(int a, int b, int c, int d, int e) | |
{ | |
int m = a; | |
int [] arr = {a, b, c, d, e}; | |
for (int i = 0; i < arr.length; i++) | |
{ | |
if (arr[i] < m) | |
{ | |
m = arr[i]; | |
} | |
} | |
return m; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment