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
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
Biology,
3 months ago
Math,
3 months ago
English,
3 months ago
English,
7 months ago
Math,
11 months ago
Social Sciences,
11 months ago
Social Sciences,
11 months ago