Created
February 23, 2016 14:42
-
-
Save alexejVasko/ec3a82bb55981a798be5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 task1; | |
| import java.util.Scanner; | |
| /* | |
| * Task 1 | |
| * create method displayMaximum(), displayMaximum() and displayAverage() | |
| * */ | |
| public class Lesson3IfStatement { | |
| public static void main(String[] args) { | |
| Scanner scanner = new Scanner(System.in); | |
| int a=scanner.nextInt(); | |
| System.out.println("a=" + a); | |
| int b=scanner.nextInt(); | |
| System.out.println("b=" + b); | |
| int c=scanner.nextInt(); | |
| System.out.println("c=" + c); | |
| System.out.println(); | |
| displayMinimum(a, b, c); | |
| displayMaximum(a, b, c); | |
| displayAverage(a, b, c); | |
| } | |
| private static void displayMaximum(int a, int b, int c){ | |
| int max=0; | |
| if (a>b && a>c){ | |
| max = a; | |
| } | |
| else if (b>a && b>c){ | |
| max = b; | |
| } | |
| else if (c>a && c>b) | |
| max = c; | |
| System.out.println("max=" + max); | |
| } | |
| private static void displayMinimum(int a, int b, int c){ | |
| int min=0; | |
| if (a<b && a<c){ | |
| min = a; | |
| } | |
| else if (b<a && b<c){ | |
| min = b; | |
| } | |
| else if (c<a && c<b) | |
| min = c; | |
| System.out.println("min=" + min); | |
| } | |
| private static void displayAverage(int a, int b, int c){ | |
| int average = (a+b+c)/3; | |
| System.out.println("average =" + average); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment