0% found this document useful (0 votes)
6 views

Java-Mermaid Hackathon

Uploaded by

S D Venkatesh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Java-Mermaid Hackathon

Uploaded by

S D Venkatesh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

JAVA-MERMAID HACKATHON

SECTION - A Marks: 80

Answer any 4 questions out of 5.

1. (a) Write a Java Program to reverse the words of a string.


Input : “Hello World”
Expected Output : “World Hello”

Input : “Java”
Expected Output : “Java”

(b)Write a Java Program to find the second smallest number in the array.
Input : {1,4,9,2}
Expected Output : 2

2. Write a Java program to find if the given number is a Strontio or not.


Strontio number are those four digit numbers when multiplied by 2 give the
same digit at the hundred and tens place. Remember that the input number must
be a four digit number.
Input : 1386( 1386 x 2 = 2772)
Expected Output : The given number is Strontio number.

3. Write a Java program to print the prime numbers from the given range.
Input : 10 - 20
Expected Output : 11, 13, 17, 19

4. Write a Java program to print Hailstone Sequence for a given number.


Take a number (says ‘n’) as an input.
a) Print the value of ‘n’.
b) If ‘n’ is odd, calculate the next number as n*3+1.
c) If ‘n’ is even, calculate the next number as n/2.
d) Do this process until the value of ‘n’ is not 1.
Example:
Input : 10
Expected Output : 10 -> 5 -> 16 -> 8 -> 4 -> 2 ->1
5. Write a Java program to determine whether one string is a rotation of another or
not.
Input : “abcde” , “deabc”
Expected Output : true

Input : “listen” , “silent”


Expected Output : true

SECTION - B

Draw any 2 Sequence Diagrams out of 3.

1. Draw the sequence diagram for the given situation.

You place an order for a product, but it is not delivered within the scheduled
time. As a result, you call customer service to inquire about the issue. Include
the following steps mandatorly.

● Press 1 for general enquiries


● Press 2 for complaints
● Press 3 for delivery-related concerns

Based on the button you press, the conversation proceeds accordingly.

2. Draw a sequence diagram for the given situation.


The situation involves using any app to make a payment. Add each of these
given prerequisites.

● Show both valid and invalid cases in the early validations.


● Following UPI pin entry, display both valid and incorrect scenarios.
● Ask yourself if you should ban or accept the person if they are not listed
in your contacts.

3. Draw a sequence diagram for the given scenario.


Here, the driver and the customer share their location via the server.First, the
driver authenticates with the server using their ID, and then the customer
authenticates with the server using their ID. Only servers are permitted to
connect if the IDs are valid; otherwise, disconnect.The customer then makes a
ride request.After accepting the ride, the driver shares his real-time location
continuously till the driver arrives at the customer's location and notify the
customer that he reaches the pickup location. After the ride begins again the
driver shares his real-time location continuously till the driver arrives at the
destination location and driver will notify the customer that he reached the
destination.

Note: The Driver and Customer do not communicate directly with one another.
Via Server, all is done.

SECTION - C

Draw any 2 Flowcharts out of 3.

1. Draw a flowchart for the given scenario.


Imagine you’re developing a simple text analysis tool for a word processor
application. Your task is to create a feature that counts and displays the number
of vowels and consonants in any word typed by the user. How would you
design a flowchart to accomplish this task?

2. Draw the flowchart for the given scenario

Validating Organisation Registration IDs


Background:
To register an organisation, the system requires a unique 12-digit ID. This ID
must meet specific criteria to be considered valid. The ID is divided into three
segments of 4 digits each. The validation process ensures the ID adheres to the
following rules:

The ID is exactly 12 digits long. If not, return "Invalid ID."

The ID should be split into three 4-digit numbers:


First Number: The first 4 digits(1-4) of the ID.
Second Number: The next 4 digits(5-8) of the ID.
Third Number: The last 4 digits(9-12) of the ID.

The following conditions must be met:


The First Number should be less than both the Second Number and the Third
Number.
The Second Number should be less than the Third Number.
The three numbers should be arranged in ascending order.

Return Result:

If all conditions are met, return "Valid ID."


Otherwise, return "Invalid ID."

Example IDs:

123415662000: This ID is valid because 1234 < 1566 < 2000.


999912343234: This ID is invalid because 9999 is not less than 1234 and 3234.

3. Draw a flowchart for the given scenario.


Imagine you’re creating a simple number game for a mobile app. The game
works as follows: the player enters a number, and the app performs a series of
arithmetic operations on that number: it doubles the number, multiplies the
result by 10, divides that result by 2, and finally divides the result by 10. If the
final result equals the original number, the player wins. How would you design
a flowchart to illustrate this process, showing each arithmetic operation
clearly?

*** END ***

You might also like