Write a program of Kids School Example In java

 
 Question:

In a school, the Kindergarten students are supposed to repeat a word 5 times. For example, if the word is “dancing”, they will have to say dancing dancingdancingdancingdancing.

Write a program to accept the string(word) as input from the user and also get the X and the Y position of the character as input from the user. If the Xth and Yth position characters are the same then print it as “Same” else “Not Same”.

[Example: if the input is dancing, and if the x is 3 and y is 10 then the output will be “Same”. The students keep on repeating the word for 5 times, the 3rd position character is “n” and the 10th position character is also “n” so the output is the same]

Sample Input 1:

Dancing

3

10

Sample output 1:

Same

Sample Input 2:

love

2

12

Sample output 2:

Not Same

Read more

Write a program to print the characters in descending order In java

Question:-

Write a Java program to get the String input from the user and display the alphabets in the String in descending order.

(Assume all the characters are given in lower case).

Note: In the String “programming” the characters m or r or g is repeated.

Sample Input 1:

love

Sample output:

vole

Sample Input 2:

programming

Sample output 2:

Rponmiga

Read more

Write a program to Create Login Page In java


Question:

Login Page

Antony and his friends plan to create an application. They decide to create a login page. Users need to register their details and log in before using the application.

They need to create a login page where only the registered user can log in Create a Java program to help them create a simple model for their application by getting registration details, storing them, and verifying the login process.

Note:

  • Registered Username must contain at least 4 characters and should not contain any space. If not, print “Invalid Username” and terminate the program.
  • Registered Password must contain at least * characters and should not contain any space. If not, print “Invalid Password” and terminate the program.
  • If registered username and password (Case Sensitive) satisfies the above condition then print “Registered Successfully” and continue to ask for login details.
  • If Login Username and Password is equal to the previously Registered Username and Password then print “Welcome <User Name> you have Logged-in Successfully” else print “Username or Password Mismatch”

Please do not use System. exit(0) to terminate the program

Read more

Write a program to Box Challenge In java

Write a program to Box Challenge In java


Question:

Mr. Emun gives a task to his son Maran. Mr. Emun has a box, which contains numbers only. The task for Maran is to find if the box is valid or invalid. If the sum of the last digits of all the numbers in the box is even then it is a valid box. If the sum of the last digits of all the numbers is odd then it is an Invalid box. Create a java application to help Maran check if the box is Valid or Invalid.

Note:

  • The input numbers must be greater than zero. Else display “ is not a valid input” and terminates.
  • If the sum is even, then print “ is even it’s a valid box”.
  • If the sum is odd, then print “ is odd it’s an invalid box”.
  • The box cannot contain balls less than zero, if so print ” is not a valid input”. Please don’t use System. exit(0) to terminate the program.

Sample Input 1:

The box contains

6

Enter the numbers

5

55

3

59

42

8

Sample Output 1:

32 is even its valid box

Explanation:

The sum of all last digits (5+5+3+9+2+8=32) is 32, it’s even. So, the box is valid

Sample Input 2:

The box contains

5

Enter the numbers

32

1

858742

56

95254

Sample Output 2:

15 id odd its invalid box

Read more

Write a program to Fetch Mid Characters In java

Write a program to Fetch Mid Characters In java

Question:

Write a Java Program to read a string from the user and fetch the middle characters that feature in the center of the string from the input string and return it as string output.

  1. 1. The Minimum string size should be of 3 characters. If not, print “The string <string> is too short”.
  2. 2. String should have only Alphabets. If not, print “The string should not have <special character/ numbers>”.

Assumption:

Read more

Minimum Steps – Hacker Earth Problem Solution

Minimum Steps - Hacker Earth Problem Solution


There are three integers k,m,n. You have to convert the number k to m by performing the given operations:

  • Multiply k by n
  •  Decrease k by 2.
  •  Decrease k by 1.
You have to perform the above operations to convert the integer from k to m and find the minimum steps.
Note: You can perform the operations in any order.
Input : –
 
First-line contains the number of test cases T.
The next T line contains three space-separated integers k, m, and n.
Output : –
Print minimum no. of steps as output in a new line for each test case.

Read more