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
Computer Science,
3 months ago
Economy,
3 months ago
Computer Science,
3 months ago
English,
6 months ago
Math,
10 months ago
Social Sciences,
10 months ago
Social Sciences,
10 months ago