Jiskha Homework Help
SATURDAY
November 21, 2009
SCHOOL SUBJECTS
- Art
- Business
- Computers
- English
- Foreign Languages
- Health
- Home Economics
- Math
- Music
- Physical Education
- Science
- Social Studies
GRADE LEVELS
- Preschool
- Kindergarten
- Elementary School
- 1st Grade
- 2nd Grade
- 3rd Grade
- 4th Grade
- 5th Grade
- 6th Grade
- 7th Grade
- 8th Grade
- High School
- 9th Grade
- 10th Grade
- 11th Grade
- 12th Grade
- College
- Adult Education
Post a New Question | Current Questions | Chat With Live Tutors

Homework Help Forum: java programming

Posted by mark on Tuesday, July 7, 2009 at 6:19pm.

could someone help me create a source code that requires you to enter 2 numbers then gets the sum, difference, product and quotient of them after entering

  • java programming - Marth, Tuesday, July 7, 2009 at 6:27pm

    public static void main(String[] args)
    {
    // input
    Scanner kb=new Scanner(in);

    // input 2 doubles
    double num1=kb.nextDouble();
    double num2=kb.nextDouble();

    // sum
    out.println(num1+num2);

    // difference
    out.println(num1-num2);

    // product
    out.println(num1*num2);

    // quotient
    out.println(num1/num2);
    }

  • java programming - MathMate, Tuesday, July 7, 2009 at 8:01pm

    If you use the Scanner class, you would have to import the java.util.Scanner class before your first use.

    You can use the Scanner class to get input by creating an instance
    Scanner sc=new Scanner(System.in);
    which will use the console input for your data.
    To print (without carriage return), you could use
    System.out.print("string/message");
    To print with carriage return, you could use:
    System.out.println(""+data +"messages");
    Integer data will be converted to Sting and concantenated with any String data.
    you need to define the integer variables using
    int k1,k2;
    and input using the Scanner class, for example:
    k1=sc.nextInt();
    This resumes much of the commands you will need. Use the Java API to help you with syntax, and post your rough copy if you need more help.

  • java programming - MathMate, Tuesday, July 7, 2009 at 8:03pm

    In case you don't have the Java API installed, it can be found at the following link:
    http://java.sun.com/javase/6/docs/api/

Answer this Question

First Name:
School Subject:
Answer:

SEARCH

COMMUNITY
FEATURES
- Live Tutors
- Net Riddle
- Reference
- Search