Advertisement
StefanTobler

Lesson 29 Activity 2

Nov 4th, 2016
1,196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. /*
  2.  * Lesson 29 Coding Activity 2
  3.  * Write a loop that processes an array of strings.
  4.  * Each String should be printed backwards on its own line.
  5.  *
  6.  * For example, if the list contains:
  7.  *    
  8.  *     {"every", "nearing", "checking", "food", "stand", "value"}
  9.  *
  10.  * It should output:
  11.  *     yreve
  12.  *     gniraen
  13.  *     gnikcehc
  14.  *     doof
  15.  *     dnats
  16.  *     eulav
  17.  */
  18.  
  19. import java.util.Scanner;
  20. import java.lang.Math;
  21.  
  22. class Lesson_29_Activity_Two {
  23.  
  24.     /* Fill this list with values that will be useful for you to test.
  25.    * A good idea may be to copy/paste the list in the example above.
  26.    * Do not make any changes to this list in your main method. You can
  27.    * print values from list, but do not add or remove values to this
  28.    * variable.  
  29.    */
  30.     public static String [] list = {"every", "nearing", "checking", "food", "stand", "value"};
  31.    
  32.     public static void main(String[] args)
  33.      {
  34.       StringBuffer word = new StringBuffer("");
  35.       int x = 0;
  36.       for (int i = 0; i < list.length; i++)
  37.       {
  38.         word = new StringBuffer(list[i]);
  39.         word.reverse();
  40.         System.out.println(word);
  41.  
  42.       }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement