Results 1 to 3 of 3
  1. #1
    MY QUESTION is offline Member
    Join Date
    Apr 2013
    Posts
    1
    Rep Power
    0

    Default How do I improve this?

    I want to add more to this project, but I don't know what to add to it! Is there something I can do to make this better/more fun/cool/etc.? Thanks

    public class S1P1
    {
    public static void main (String[] args) throws Exception

    {

    int num1 = (int) (Math.round(Math.random()*10));

    int num2 = (int) (Math.round(Math.random()*10));

    int sign = (int) (Math.round(Math.random()*3));

    int answer = 0;

    System.out.println ("\n\n*****");

    if (sign==0 )

    {

    System.out.println(num1+ "*" +num2);
    answer = num1*num2;
    }
    else if (sign==1)

    {

    System.out.println (num1+" / "+num2);
    answer = num1/num2;
    }

    else if (sign==2)

    {
    System.out.println(num1+" + "+num2);
    answer = num1+num2;

    }

    else if (sign==3)
    {
    System.out.println(num1+" - "+num2);
    answer = num1-num2;
    }

    System.out.println ("*****\n");

    System.out.println("5 ...");
    Thread.sleep(1000);

    System.out.println("4 ...");
    Thread.sleep(1000);

    System.out.println("3 ...");
    Thread.sleep(1000);


    System.out.println("2 ...");
    Thread.sleep(1000);


    System.out.println("1 ...");
    Thread.sleep(1000);

    System.out.println("ANSWER: "+answer);

    }
    }

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,763
    Blog Entries
    7
    Rep Power
    21

    Default Re: How do I improve this?

    Quote Originally Posted by MY QUESTION View Post
    I want to add more to this project, but I don't know what to add to it! Is there something I can do to make this better/more fun/cool/etc.? Thanks

    Java Code:
    ...
     else if (sign==1)
    
     {
    
     System.out.println (num1+" / "+num2); 
     answer = num1/num2;
     }
    ...
    What happens is num2 is zero?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    393
    Rep Power
    5

    Default Re: How do I improve this?

    Java Code:
    for(int i = 5; i > 0; i--)
    {
    System.out.println(i + " ...");
    Thread.sleep(1000);
    }
    Regards.

Similar Threads

  1. What can i do to improve this? Explanation please
    By biggerthanblue in forum New To Java
    Replies: 1
    Last Post: 02-19-2011, 07:55 AM
  2. Improve my GUI!
    By AJArmstron@aol.com in forum New To Java
    Replies: 8
    Last Post: 04-27-2010, 10:17 PM
  3. How to improve this code
    By Raymond in forum Advanced Java
    Replies: 9
    Last Post: 03-19-2010, 09:16 AM
  4. How to improve Jslider
    By JohnST in forum New To Java
    Replies: 3
    Last Post: 01-12-2010, 02:04 AM
  5. how to improve the performance of JWS?
    By dinesh kaushik in forum Java Applets
    Replies: 0
    Last Post: 11-21-2007, 09:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •