Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Quiz{
- public static void main(String[] args)
- {
- int[] myArray = {0, 1, 2, 3, 4, 5, 6, 7};
- ShowArray(myArray);
- ShowReverseArray(myArray);
- ShowArraySum(myArray);
- }
- public static void ShowArraySum(int[] arrayData){
- int value = 0;
- for(int i=0;i<=7;i++){
- value = value + arrayData[i];
- }
- System.out.println("Sum: \n" + value + "\n");
- }
- public static void ShowArray(int[] arrayData){
- String reply = "";
- for(int i=0;i<=7;i++){
- reply += arrayData[i] + "\n";
- }
- System.out.println("Normal: \n" + reply + "\n");
- }
- public static void ShowReverseArray(int[] arrayData) {
- String reply = "";
- for(int i=7;i>=0;i--){
- reply += arrayData[i] + "\n";
- }
- System.out.println("Reverse: \n" + reply);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement