Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static int produkt(int n1, int n2) {
- return n1 * n2;
- }
- public static int potenca(int n) {
- return (int) Math.pow(n, 5);
- }
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- int a;
- int b;
- int c;
- System.out.println("Enter value of a (1-9): ");
- while ((a = s.nextInt()) < 1 || a > 9) {
- System.out.printf("%d is out of range (1-9)\n Please try again:\n", a);
- }
- System.out.println("Enter value of b (1-9): ");
- while ((b = s.nextInt()) < 1 || b > 9) {
- System.out.printf("%d is out of range (1-9)\n Please try again:\n", b);
- }
- System.out.println("Enter value of c (1-9): ");
- while ((c = s.nextInt()) < 1 || c > 9) {
- System.out.printf("%d is out of range (1-9)\n Please try again:\n", c);
- }
- s.close();
- System.out.println("Product of 'a' and 'b' = " + produkt(a, b));
- System.out.println("Product of 'a' and 'b' = " + produkt(a, c));
- System.out.println("Product of 'a' and 'b' = " + produkt(b, c));
- System.out.println("a^5 = " + potenca(a));
- System.out.println("b^5 = " + potenca(b));
- System.out.println("c^5 = " + potenca(c));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement