Results 1 to 6 of 6

Thread: Help Needed^^

  1. #1
    hitech83 is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Default Help Needed^^

    hey!
    can you please schow me how to wright code for this simple basic programe witch add a number to another!
    i am new here and in java world programming,so i did beginn wrighting the code ;) but i don't have an idea how to use If Statment?here is a picture witch explan evry thing.

    http://picasaweb.google.com/lh/photo...eat=directlink

    thx:confused:

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    What have you done so far? Did you google how to write an if statement? I highly doubt someone is going to hand over code to you unless you show you have made an effort, either through code snippets, google searches, etc...Based upon your question here is a suggested starting point:
    The Java™ Tutorials

  3. #3
    hitech83 is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Default hi

    i did beginn <wright code for this simple program,and i do can use sample IF stamtment,but here i musst use it for char and int types :

    this what i did so far and its not good :

    import static java.lang.System.out;
    import java.util.Scanner;
    class Adition {
    public static void main(String args[]){
    Scanner MyScanner = new Scanner(System.in);
    int FirstNum;
    int SecondNum;
    int Somme;
    FirstNum=MyScanner(System.in);
    out.print("Enter your First Number! :");
    SecondNum=MyScanner(System.in);
    out.print("Enter Your Second Number! :");
    Somme=FirstNum+SecondNum;
    out.print("Your Somme Is : ");
    out.println(Somme);
    }
    }

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    please put code from now on in code tags. You pretty much have it figured out, the scanner is created correctly, the problem is, you want to prompt for a number before setting firstnum to scanner something. Also, look up scanner methods, mainly nextInt().
    Scanner (Java 2 Platform SE 5.0)

  5. #5
    hitech83 is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Default

    thx for your help!!!

    [code] import static java.lang.System.out;
    import java.util.Scanner;
    class apples{
    public static void main(String args[]){
    Scanner myscanner = new Scanner(System.in);
    int fnum, snum, answer;
    out.println("Enter Your First Number :");
    fnum = myscanner.nextInt();
    out.println("Enter Your Second Number :");
    snum = myscanner.nextInt();
    answer = fnum + snum;
    out.print("Yoour Somme Is : ");
    out.println( answer);
    }
    }
    [ /code]

  6. #6
    hitech83 is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Default

    thx for your help!!!

    [code] import static java.lang.System.out;
    import java.util.Scanner;
    class apples{
    public static void main(String args[]){
    Scanner myscanner = new Scanner(System.in);
    int fnum, snum, answer;
    out.println("Enter Your First Number :");
    fnum = myscanner.nextInt();
    out.println("Enter Your Second Number :");
    snum = myscanner.nextInt();
    answer = fnum + snum;
    out.print("Yoour Somme Is : ");
    out.println( answer);
    }
    }
    [ /code]

Similar Threads

  1. Help Needed
    By 7auz in forum Eclipse
    Replies: 1
    Last Post: 09-30-2010, 05:59 PM
  2. Help Needed Please
    By ajaxjagadish in forum Advanced Java
    Replies: 1
    Last Post: 02-12-2010, 07:25 PM
  3. Help Needed
    By jyothi_tallapaneni in forum Advanced Java
    Replies: 1
    Last Post: 02-11-2010, 07:07 PM
  4. Help needed
    By harshalsakpal in forum CLDC and MIDP
    Replies: 0
    Last Post: 02-17-2009, 03:53 PM
  5. Help Needed
    By pks in forum New To Java
    Replies: 1
    Last Post: 01-09-2008, 12:07 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
  •