Question Index

Write a program to print the classification for every integer in the given range. E for even, O for odd, OX for odd and divisible by 3, OXY for odd and divisible by 9, OXYZ for odd and divisible by 27. When printing the integer should be prefixed and suffixed with tilda(~).
RULES: Do not use nested if's or Boolean logical AND(&) operator in the program.

Input (Integer Range) Output Printed
20 to 28 ~20~E~21~OX~22~E~23~O~24~E~25~O~26~E~27~OXYZ~28~E
1 to 10 ~1~O~2~E~3~OX~4~E~5~O~6~E~7~O~8~E~9~OXY~10~E
80 to 85 ~80~E~81~OXYZ~82~E~83~O~84~E~85~O

class ClassifyIntegers

{    public static void main(String s[])
        classifyIntegers(20, 40);


public static void classifyIntegers(int start, int end)
//Write code here to classify the integers as mentioned in the question.



Topic: Java continue Statement

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App