Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.31 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.Scanner;
  3.  
  4. public class RateOfDecay {
  5.   public static void main (String[] args){
  6. /*************************************************
  7.  *            Variables go here                  *
  8.  *************************************************/
  9.     // Large number between 10000 and 100000
  10.     int largeInt;
  11.     // Probability number (Not sure what is specified here)
  12.     double probability;
  13.  
  14.     //creating the Scanner
  15.     Scanner reader = new Scanner(System.in);
  16.  
  17.     //Taking in the large number
  18.     System.out.println("Enter the large number:");
  19.     largeInt = reader.nextInt();
  20.     // PlaceHolder Number
  21.     double newDouble = largeInt;
  22.  
  23.     // Taking in the probability
  24.     System.out.println("Enter the probability:");
  25.     probability = reader.nextDouble();
  26.  
  27.     /***************************************************************************
  28.     The code below is a loop to go over the seconds.
  29.     When each second is displayed, it indictates the number of
  30.     atoms left.
  31.  
  32.     From what I can gather, the large input number is the number of Atoms
  33.     of the substance that is left after a specific amount of time has passed.
  34.     So a simple loop will do, to keep going as as long as the number is greater
  35.     than 1/16 (0.0625) of the original mass. Multiplying the probability and the
  36.     current large number and subtracting it from the current large number will
  37.     whittle it down.
  38.  
  39.     **********************************READ*PLS***************************************
  40.     * You will probably have to work a little and create your probability number    *
  41.     * This question is not complete yet. Once you have some more clarification      *
  42.     * about what the probability number is, and how it is determined, then you can  *
  43.     * just plug that into the loop down below and let it run. The Skeleton has been *
  44.     * done for you!  Good luck!                                                     *
  45.     *********************************************************************************
  46.  
  47.     I hope that this helps!
  48.    
  49.     ***************************************************************/
  50.     for(int i = 0; newDouble >= (0.0625 * largeInt); i++){
  51.       newDouble = newDouble - (newDouble * probability);
  52.       System.out.println("Second " + i + ": "+ newDouble);
  53.     }
  54.  
  55.   }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement