Computer Science, asked by kanustory, 7 months ago

Write the given code using if' statement to avoid
mumber of comparisons :
System.out.println("One");
System.out.println("Two");
System.out.println("Three");
System.out.println("Four");
System.out.println("Five");​

Answers

Answered by harshans164
2

Public class sample

{

Public Static void main(String []args)

{

String 1=one;

String 2=two;

String 3=three;

String 4=four;

String 5=five;

int s=1;

For(int i=0;i<5;i++);

{

System.out.println(s);

String++;

}

}

}

Using if statement

Public class

{

Public Static void main(String []arg)

{

Int i;

For (i=0;i<5;i++)

{

If(i==1)

{

System.out.println("one");

}

If(i==2)

{

System.out.println("two");

}

If(i==3)

{

System.out.println("three");

}

If(i==4)

{

System.out.println("four");

}

If(i==5)

{

System.out.println("five");

}

}

}

}

Answered by thewatchingtime123
0

Answer:

The answer

Explanation:

Ig it'll help yah...

Attachments:
Similar questions