Results 1 to 12 of 12
  1. #1
    Aggorance's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    5
    Reputation
    10
    Thanks
    1

    Super simple Conversation Program.

    Code:
    import java.io.*;
    
    class Conversation {
    
        public static void main(String[] args) throws IOException {
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            int myAge = 15;
            System.out.println("What is your name?");
            String name = in.readLine();
            System.out.println("Your name is " + name + ", great name.");
            System.out.println("How old are you?");
            String age = in.readLine();
            System.out.println("You are " +age+".");
            System.out.print("If you added our ages together we would be" + (age + myAge) + " :)");
            System.out.println("What is your favorite hobbie?");
            String hobby = in.readLine();
            System.out.println("What do you like about " + hobby+"?");
            String otherHobby = in.readLine();
            System.out.println("So what you're saying about " + otherHobby + " is neat.");
            System.out.println("Well it was nice talking to you");
            System.out.println("Please rate this program 1 - 10");
            System.out.println("Type a number:");
            String rating  = in.readLine();
            int value = Integer.parseInt(rating); 
            if (value > 5)  {
                System.out.println("You voted: "+value+".");
            } else  {
                System.out.println("You voted: "+value+".");
    
            }
            System.out.println("End of program"); 
        }
    }

  2. The Following User Says Thank You to Aggorance For This Useful Post:

    megabajt (12-10-2012)

  3. #2
    Richtextbox's Avatar
    Join Date
    Nov 2011
    Gender
    male
    Posts
    1
    Reputation
    10
    Thanks
    0
    My Mood
    Angelic
    Bro, this is good can you expain what this mean?
    throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

  4. #3
    Saltine's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    493
    Reputation
    104
    Thanks
    629
    Quote Originally Posted by Richtextbox View Post
    Bro, this is good can you expain what this mean?
    throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    When you throw an exception, it means that the handling of a runtime error is passed off to the caller of the function which sent it, and no UI message or other such annoyance occurs. A BufferedReader is a class which is used to read a string of characters in from the console byte by byte and parse them into a String.

  5. #4
    iknowlots's Avatar
    Join Date
    Sep 2011
    Gender
    male
    Posts
    10
    Reputation
    10
    Thanks
    0
    You seem to be around the same skill level as me, and if you are - hello!
    Anyway, couldn't Scanner(in the java.util library) achieve the same thing as BufferedReader? I find Scanner more reliable than BufferedReader, as you don't have to parse into integers and that sort of stuff...

  6. #5
    Saltine's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    493
    Reputation
    104
    Thanks
    629
    Quote Originally Posted by iknowlots View Post
    You seem to be around the same skill level as me, and if you are - hello!
    Anyway, couldn't Scanner(in the java.util library) achieve the same thing as BufferedReader? I find Scanner more reliable than BufferedReader, as you don't have to parse into integers and that sort of stuff...
    They can both achieve the same thing, although I prefer to use javax.swing.JOptionPane.showInputDialog("prompt") method. It returns a string, but it is much better than console input IMO.

    Oh no! Vortex is gay!

  7. #6
    yair's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    50
    Reputation
    10
    Thanks
    1
    >.< i did this program as pratice for my java class last week lol...didnt know it was here heheheheh

  8. #7
    FLubz's Avatar
    Join Date
    Feb 2012
    Gender
    male
    Location
    L3 Cache
    Posts
    39
    Reputation
    10
    Thanks
    6
    My Mood
    Cool
    Any questions left concerning how to catch and throw exceptions and or use user-defined exceptions?
    Quote Originally Posted by 258456 View Post
    I was aimbotting people while i was in the wall and i didn't get banned.

  9. #8
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by FLubz View Post
    Any questions left concerning how to catch and throw exceptions and or use user-defined exceptions?
    Dude, sorry but this is spam !

  10. #9
    zayadur's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    New York
    Posts
    77
    Reputation
    10
    Thanks
    2
    I find the scanner class a lot more convenient, and that's probably because I use it more often than the clunky Buffer class.

  11. #10
    lollerman69's Avatar
    Join Date
    Apr 2012
    Gender
    male
    Location
    Human System, Earth
    Posts
    10
    Reputation
    10
    Thanks
    1
    My Mood
    Yeehaw
    Quote Originally Posted by yair View Post
    >.< i did this program as pratice for my java class last week lol...didnt know it was here heheheheh
    Lol me too.
    As advice I recommend making a text adventure to help with learning if statements,objects,and classes.
    Y U no use scanner keyboard!!!!
    Last edited by lollerman69; 07-26-2012 at 12:33 AM.

  12. #11
    Password77's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    Canada, ON
    Posts
    179
    Reputation
    10
    Thanks
    181
    My Mood
    Cheerful
    As much as I love buffered reader, scanner does a whole lot of job for me . Also now you might wanna grab in the output you give from a text file and manipulate using Arrays to make it more advanced
    Doing more Java and Python
    Need help with your hack? Ask me, I will try to help you with all my might .

  13. #12
    schlabie's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    23
    Reputation
    10
    Thanks
    1
    This code is really sloppy, or at least looks like it from thr mobile version. Space everything out.

Similar Threads

  1. Super Simple ESP?
    By Daygum in forum Call of Duty Modern Warfare 2 Help
    Replies: 7
    Last Post: 04-24-2010, 09:03 PM
  2. Simple VB program
    By FrostyTheSnowman in forum CrossFire Discussions
    Replies: 13
    Last Post: 04-15-2010, 06:35 AM
  3. [Release] [CS 1.6] Super Simple Wall v6.7 by <:PrOdIgY:> AKA Jimster480
    By Jimster480 in forum CounterStrike (CS) 1.6 Hacks / Counter Strike: Source (CSS) Hacks
    Replies: 0
    Last Post: 01-08-2010, 06:29 AM
  4. [Release] [CS 1.6] Super Simple Wall v6.6 by <:PrOdIgY:> AKA Jimster480
    By Jimster480 in forum CounterStrike (CS) 1.6 Hacks / Counter Strike: Source (CSS) Hacks
    Replies: 10
    Last Post: 01-07-2010, 09:15 AM
  5. [Release] Super Simple Wall v6.5
    By rfbtgn in forum CounterStrike (CS) 1.6 Hacks / Counter Strike: Source (CSS) Hacks
    Replies: 3
    Last Post: 12-10-2009, 08:35 AM