Computer Science, asked by riv13, 1 month ago

import java.util.;
class myjava
<identifier> expected
{
public static void main(String[args);
{
SC scanner = new scanner(System.in);
int first;
int second;
first =SC.nextInt;
second=SC.nextInt;
System.out.println("enter two numbers : ");. why it is showing identifier expected in the that line import ...
... where is it wrong?​

Answers

Answered by atrs7391
0

Given Program:

import java.util.;

class myjava

<identifier> expected

{

public static void main(String[args);

{

SC scanner = new scanner(System.in);

int first;

int second;

first =SC.nextInt;

second=SC.nextInt;

System.out.println("enter two numbers : ");

Rectified Program:

import java.util.*;

class myjava

{

public static void main(String[] args)

{

Scanner SC = new Scanner(System.in);

int first;

int second;

first =SC.nextInt();

second=SC.nextInt();                

System.out.println("enter two numbers : ");                

}

}

Explanation:

There were many syntax errors like wrong import statement, wrong method declaration, etc..

Note:

I've just rectified the syntax errors and not logical errors. The program will run fine.

Similar questions