Java program that adds 10 points to a number input by user -Function name: addTe
ID: 672078 • Letter: J
Question
Java program that adds 10 points to a number input by user -Function name: addTen -Function accepts an integer variable named "number" -function body asks user to enter a number and then add 10 to the number. Answer stored in variable "number" - Return statement should return the value of variable numberBest solution possible
Java program that adds 10 points to a number input by user -Function name: addTen -Function accepts an integer variable named "number" -function body asks user to enter a number and then add 10 to the number. Answer stored in variable "number" - Return statement should return the value of variable number
Best solution possible
Java program that adds 10 points to a number input by user -Function name: addTen -Function accepts an integer variable named "number" -function body asks user to enter a number and then add 10 to the number. Answer stored in variable "number" - Return statement should return the value of variable number
Best solution possible
Explanation / Answer
import java.util.*;
class MyClass
{
public int addTen(int num)
{
int a = num+10;
return a;
}
}
class MainClass
{
public static void main(String args[])
{
MyClass m = new MyClass();
Scanner sc= new Scanner(System.in);
System.out.println("Enter any Number");
int a = sc.nextInt();
int n=m.addTen(a);
System.out.println("The number after adding 10 is"+n);
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.