Square of a number
Write a program that displays the square of 5 on the screen.
Requirements:
1. The program should output text.
2. The main method should call the sqr method with 5 as an argument.
3. The main method should display the result of the sqr method.
4. Don't change the sqr method.
5. The displayed text must match the task conditions.
package com.codegym.task.task01.task0127;
/*
Square of a number
*/
public class Solution {
public static void main(String[] args) {
//write your code here
}
public static int sqr(int a) {
return a * a;
}
}
I need someone to help me solve this coding challenge.
Archived
Comments (5)
- Popular
- New
- Old
You must be signed in to leave a comment
srikanth
11 March 2019, 12:14
got stuck in this code help out how to find sqr method?
package com.codegym.task.task01.task0127;
/*
Square of a number
*/
public class Solution {
public static void main(String[] args) {
//write your code here
int a;
sqr(5);
System.out.print(sqr(5));
}
public static int sqr(int a) {
return a * a;
}
}
0
Goutami ch
15 February 2019, 09:31
system.out.println(sqr(5)) in main method
0
Sindhu P
28 January 2019, 06:10
U can call the sqr function inside the main method with arguments.
0
hidden #10419982
21 January 2019, 10:45
The main method should call the sqr method with 5 as a parameter : like
sqr(5) // this how you call the sqr method with 5 as parameter
store the result in an int variable and then print the result.
+3
Akshay
21 January 2019, 09:31
//write your code here in this section we need to write below code
System.out.println(sqr(5));
+3