Facebook

adsense

Wednesday, 8 April 2015

"Mind Reader" in java code



Note :
1) Compile the program named as MindReader.java
2) In This program you have to think some number and after performing some calculation on that number , this program will tell the final answer .

import java.util.Random;
import javax.swing.JOptionPane;


public class MindReader {


     public static void main(String[] args) {
     
        Random ran = new Random();
        JOptionPane.showMessageDialog(null, "Think of some number in your mind(numeric),"
                + "\n and do following steps ", "Mind Reader" , 1);
     
        double d = ran.nextInt(199)+1;
        JOptionPane.showMessageDialog(null, "STEPS :     \n1)Double the number that you think "
                + "\n2) Add " + d + " to that number "
                + "\n3) Half that number "
                + "\n4) subtract the number you think from the present value", "Mind Reader" , 1);
        float f = (float)(d/2);
        JOptionPane.showMessageDialog(null, "The Final answer will be " + f, "Mind Reader" , 1);
    }
 
}

Sample output :


No comments:

Post a Comment