Advertisement
Guest User

foxin with jump

a guest
Dec 5th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. public class Quiz{
  2.  
  3.     public static void main(String[] args)
  4.     {
  5.         int[] myArray = {0, 1, 2, 3, 4, 5, 6, 7};
  6.         ShowArray(myArray);
  7.         ShowReverseArray(myArray);
  8.         ShowArraySum(myArray);
  9.     }
  10.  
  11.     public static void ShowArraySum(int[] arrayData){
  12.         int value = 0;
  13.  
  14.         for(int i=0;i<=7;i++){
  15.            value = value + arrayData[i];
  16.         }
  17.  
  18.         System.out.println("Sum: \n" + value + "\n");
  19.     }
  20.  
  21.     public static void ShowArray(int[] arrayData){
  22.         String reply = "";
  23.         for(int i=0;i<=7;i++){
  24.            reply += arrayData[i] + "\n";
  25.         }
  26.         System.out.println("Normal: \n" + reply + "\n");
  27.     }
  28.  
  29.     public static void ShowReverseArray(int[] arrayData) {
  30.         String reply = "";
  31.         for(int i=7;i>=0;i--){
  32.             reply += arrayData[i] + "\n";
  33.         }
  34.        
  35.         System.out.println("Reverse: \n" + reply);
  36.     }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement