FEEDBACK PLZ, basic code assignment

I know this is a C++ forum but i thought you guys might be able to help or give any feedback on this very simple JAVA assignment. i was able to get most of it done but i have been stuck what to write next, ANY FEEDBACK HELPS NEW TO CODING THANKS

ASSIGNMENT - create a program that will print

"Enter first integer: 1729
Enter second integer: 845
first + second = 2574
first - second = 844
first / second = 2
first * second = 1461005"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  import java.util.scanner;

public class program_2_1
{
public static void main(string[]args) 
{

int first_int = 0;
int second_int = 0;

scanner keyboard = new Scanner(system.in);

System.out.print("Enter first integer");
first_int = keyboard.nextint();

System.out.printin("second integer");
second_int = keyboard.nextint();

System.out.printin("first + second = " + (first_int + second_int));





}

}
You really need to test your code as you write because there are a lot of syntax errors (mostly just spelling).

String is not a primitive data type in Java, so it's declared String not string.

Indenting your code is very important as it makes your code more readable both to you and your peers. Personally, I hate a a lot of white-space. Your lines 20-24 contain an unreasonable amount white-space)

It's good practice to close your Scanner object with keyboard.close(); after your program is finished running.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import java.util.Scanner;

public class program_2_1
{
    public static void main(String[] args) 
    {
        int first_int = 0;
        int second_int = 0;
        Scanner keyboard = new Scanner(System.in);
        System.out.print("Enter first integer: ");
        first_int = keyboard.nextInt();
        System.out.println("second integer: ");
        second_int = keyboard.nextInt();
        System.out.println("first + second = " + (first_int + second_int));
        keyboard.close();
    }
}
Topic archived. No new replies allowed.