Kevin321888999

Java Absolute value, multiplication, and power

Jul 20th, 2022
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3. public class Main {
  4.     public static void main(String[] args) throws IOException {
  5.         banner();
  6.         for(;;){
  7.      malachi();
  8.      BufferedReader BR= new BufferedReader (new InputStreamReader(System.in));
  9.      System.out.println("Give an a value: ");
  10.      int a= (int)Double.parseDouble(BR.readLine());
  11.      System.out.println("Give a b value");
  12.      int b= (int)Double.parseDouble(BR.readLine());
  13.      stranded(a,b);
  14.  
  15.     }}
  16.     public static void malachi() {
  17.         System.out.println("\nPlease type a message here: ");
  18.         Scanner scanner = new Scanner(System.in);
  19.         String message = scanner.nextLine();
  20.     }
  21.     public static void stranded(int a, int b){
  22.         int sum=a*b;
  23.         int sum2=  (int)Math.pow(a,b);
  24.         System.out.println("The product is: "+ sum);
  25.         System.out.println("a to the power of b is: " + sum2);
  26.         Absolute(sum);
  27.     }
  28.     private static void Absolute(int sum){
  29.         int result= (int)Math.abs(sum);
  30.         System.out.println("The absolute value of the product of a*b: "+ result);
  31.     }
  32.     public static void banner(){
  33.         System.out.println("Malachi Sor August 20m 2022");
  34.         System.out.println("-----------------------------------------\n");
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment