Guest User

SolarAquarion HW

a guest
May 10th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. /*
  2.  * <Solar Aquarion>
  3.  * <Student ID>
  4.  * PP1.java
  5.  * Created on <Date>, at <Specific Time>
  6.  */
  7.  
  8. /******************************************************************************
  9.  * public class PP1.
  10.  *
  11.  * 1) Declares constant Max with value of 5
  12.  * 2) Declares the integers count and number (=1) in the main method
  13.  * 3) Loops 5 times with Max bounding the iteration
  14.  *  a) Changes the Value of number by adding the current value * Max to itself
  15.  *  b) Outputs this value on a separate line for each iteration
  16.  * 4) After the loop, declares and assigns the variable total as having the
  17.  *    LAST value of number divided by three in such a way that the answer
  18.  *    will have decimal points.
  19.  * 5) Outputs the total with he string "Output is: " followed by the value of
  20.  *    the total in such a way that there is space between the string and the
  21.  *    value of total
  22.  * @author SolarAquarion
  23.  *****************************************************************************/
  24. public class PP1
  25. {
  26.   //Fields
  27.   final static private int Max = 5; //(1)
  28.  
  29.   //Methods
  30.   public static void main(String [ ] args)
  31.   {
  32.     int count, number = 1; //(2)
  33.    
  34.     for (int i = 0; i < Max; i++) //(3)
  35.     {
  36.       number += (number * Max); //(3a)
  37.       System.out.println("At iteration " + (i + 1) +
  38.               ", the value of number is: " + number); //(3b)
  39.     } //for i < Max
  40.    
  41.     double total = (double)number / 3.00; //(4)
  42.     System.out.println("Output is: " + total + "\n");  
  43.   } //main()
  44. } //class PP1
Advertisement
Add Comment
Please, Sign In to add comment