Computer Science, asked by Inflameroftheancient, 1 year ago

Develop a Programming Language (in Java) to show the middle digit of that number when a string of number has been entered in it. Show the output clearly.... along with it's input with end line comments for better understanding....

Conditions for that would be producing a output if the number is even (don't display the middle digit number) and if odd (middle digit should be shown)...

Answers

Answered by siddhartharao77
28

import java.util.*;

class Brainly

{

public static void main(String args[])

{

int num1, num2,num3;

String a,b;

Scanner demo = new Scanner(System.in);

a = demo.nextLine();

num3 = a.length();

System.out.println("Number of letters: "+num3);

if((num3%2) == 0)

{

System.out.println("Even");

}

else

{

System.out.println("Odd");

}

if((num3 % 2) == 1)

{

num1 = num3 / 2;

num2 = 1;

b = a.substring(num1,num1 + num2);

System.out.println("The middle character is: "+b);

}

else

{

System.out.println("Don't hurt someone whose intention is to love you");

}

}

}



Hope it helps!

Attachments:

siddhartharao77: welcome
Anonymous: :-)
siddhartharao77: :-)
Answered by bansalchirayu7b12254
1

Answer:

hi hello mark as brainliest please

Explanation:

follow me please please please please please please

Similar questions