Skip to main content
InfyTQ Assignment Coding Solution Java
Implement a program to calculate the product of three positive integer values. However, if one of the integers is 7, consider only the values to the right of 7 for calculation. If 7 is the last integer, then display -1.
Note: Only one of the three values can be 7.
The logic we have to use the if-else conditions
class Tester { public static void main(String[] args) { // your code here int num1 =7,num2=6,num3=6; int product =0; if(num3==7){ System.out.println(product=-1); } else if (num2 ==7 ){ System.out.println(product=num3); } else if (num1 ==7 ){ System.out.println(pclassroduct=num2*num3); } else{ System.out.println(product =num1*num2*num3); } }}

Comments
Post a Comment