Computer Science, asked by ridhimasarawgi1, 7 months ago

Write a java program that defines the following methods : assign():that assigns value to a number accepted from the user. double twice(): that doubles the number assigned above and returns the result. display() : that displays the result.​

Answers

Answered by SwapnilMehta
3

Answer:

class pro

{

void assign ()

{

Scanner sc=new Scanner ("System.in);

System.out.println("Enter the no.");

int n=sc.nextInt();

}

double twice()

{

double tw=2*n;

return tw;

}

void display ()

{

System.out.println("Result is "+ twice();

}

}

Explanation:

Hope it will help you .

Do Subscribe my Channel Study To Study ICSE-Swapnil Mehta

Thank you

Similar questions