Saturday, 19 November 2022

selection Control Structure - Assignment 4

 Selection Control Structure - Assignment 4

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.

 

Sample Input and Output



class Tester{
public static void main(String[]args){
int a=2,b=6,c=7;
int x=0;
if(a==7)
{
x=b*c;
}
else if(b==7)
{
x=c;
}
else if(c==7)
{
x=-1;
}
else
{
x=a*b*c;
}
System.out.println(x);
}
}


No comments:

Post a Comment

Free Resume Template

Creating a blog post that discusses the pros and cons of using a resume rule is a great way to provide valuable information to job seekers ...