Skip to content

Instantly share code, notes, and snippets.

@roma-sck
Created December 24, 2014 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roma-sck/caf99e11ebf5e277bb4b to your computer and use it in GitHub Desktop.
Save roma-sck/caf99e11ebf5e277bb4b to your computer and use it in GitHub Desktop.
test.level05.lesson12.bonus02
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