User-Defined Methods — Question 37
Back to all questionsQuestion 35
Write a complete Java program that invokes a function satis() to find whether four integers a, b, c, d sent to satis( ) satisfy the equation a3 + b3 + c3 = d3 or not. The function satis( ) returns 0 if the above equation is satisfied with the given four numbers otherwise it returns -1.
import java.util.Scanner;
class KboatCheckEquation
{
int satis(int p,
int q,
int r,
int s) {
int res;
double lhs = Math.pow(p,3)
+ Math.pow(q,3)
+ Math.pow(r,3);
double rhs = Math.pow(s,3);
if(lhs == rhs)
res = 0;
else
res = -1;
return res;
}
public static void main(String args[])
{
KboatCheckEquation obj = new KboatCheckEquation();
Scanner in = new Scanner(System.in);
System.out.print("Enter a: " );
int a = in.nextInt();
System.out.print("Enter b: " );
int b = in.nextInt();
System.out.print("Enter c: " );
int c = in.nextInt();
System.out.print("Enter d: " );
int d = in.nextInt();
int res = obj.satis(a, b, c, d);
if(res == 0)
System.out.println("Equation satisfied");
else
System.out.println("Equation not satisfied");
}
}Output


Key Concepts Covered
This question tests your understanding of the following concepts from the chapter User-Defined Methods: Question, Complete, Java, Program, Invokes, Satis. These are fundamental topics in Computer Applications that students are expected to master as part of the ICSE Class 10 curriculum.
A thorough understanding of these concepts will help you answer similar questions confidently in your ICSE examinations. These topics are frequently tested in both objective and subjective sections of Computer Applications papers. We recommend revising the relevant section of your textbook alongside practising these solved examples to build a strong foundation.
How to Approach This Question
Read the question carefully and identify what is being asked. Break down complex questions into smaller parts. Use the terminology and concepts discussed in this chapter. Structure your answer logically — begin with a definition or key statement, then provide supporting details. Review your answer to ensure it addresses all parts of the question completely.
Key Points to Remember
- Write programs with proper indentation and comments.
- Trace through your code with sample inputs to verify correctness.
- Explain the logic behind each step of your solution.
- Familiarise yourself with common library functions and methods.
Practice more questions from User-Defined Methods — Computer Applications, Class 10 ICSE