SlideShare a Scribd company logo
1 of 3
Implement a method named letter that accepts a lowercase String of 2 letters. The method will
return the letter that is midway between them. Example: if the String is "am" the return would
be g (which is the letter midway between a and m).
Solution
/* java code to find middle character between two character */
import java.util.*;
import java.util.Scanner;
public class Midway
{
public static char mid(char start, char end)
{
int s = (int)start;
int e = (int)end;
int ascii = (s+e)/2;
char character = (char)ascii;
return character;
}
public static void main(String[] args)
{
// input string
Scanner sc=new Scanner(System.in);
System.out.print("Enter lowecase string of 2 letters: ");
String letters = sc.next();
// determining the two characters
char start = letters.charAt(0);
char end = letters.charAt(1);
if((int)start == (int)end)
System.out.println("Both characters aree Equal No middle character found ");
else if((int)start+1 == (int)end || (int)end+1 == (int)start )
System.out.println("No middle character found ");
else
{
char middle_character = mid(start,end);
System.out.println("Middle character is " + middle_character + " ");
}
}
}
/*
Output :
Enter lowecase string of 2 letters: aa
Both characters aree Equal
No middle character found
Enter lowecase string of 2 letters: ab
No middle character found
Enter lowecase string of 2 letters: ba
No middle character found
Enter lowecase string of 2 letters: ac
Middle character is b
Enter lowecase string of 2 letters: am
Middle character is g
*/
Implement a method named letter that accepts a lowercase String of 2 l.docx

More Related Content

Similar to Implement a method named letter that accepts a lowercase String of 2 l.docx

Similar to Implement a method named letter that accepts a lowercase String of 2 l.docx (12)

Find an LCS of X = and Y = Show the c and b table. Attach File .docx
  Find an LCS of X =  and Y =   Show the c and b table.  Attach File  .docx  Find an LCS of X =  and Y =   Show the c and b table.  Attach File  .docx
Find an LCS of X = and Y = Show the c and b table. Attach File .docx
 
Unitii string
Unitii stringUnitii string
Unitii string
 
[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++
 
131 Lab slides (all in one)
131 Lab slides (all in one)131 Lab slides (all in one)
131 Lab slides (all in one)
 
The Morse code (see Table 6.10 in book) is a common code that is use.pdf
The Morse code (see Table 6.10 in book) is a common code that is use.pdfThe Morse code (see Table 6.10 in book) is a common code that is use.pdf
The Morse code (see Table 6.10 in book) is a common code that is use.pdf
 
Team 1
Team 1Team 1
Team 1
 
Chap 8(strings)
Chap 8(strings)Chap 8(strings)
Chap 8(strings)
 
Strings
StringsStrings
Strings
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Computer programming 2 Lesson 12
Computer programming 2  Lesson 12Computer programming 2  Lesson 12
Computer programming 2 Lesson 12
 
Java string , string buffer and wrapper class
Java string , string buffer and wrapper classJava string , string buffer and wrapper class
Java string , string buffer and wrapper class
 
Lecture 3.pptx
Lecture 3.pptxLecture 3.pptx
Lecture 3.pptx
 

More from tristans3

In a symmetric multiprocessor configuration- AH processors can perform.docx
In a symmetric multiprocessor configuration- AH processors can perform.docxIn a symmetric multiprocessor configuration- AH processors can perform.docx
In a symmetric multiprocessor configuration- AH processors can perform.docxtristans3
 
In consumer behavior we discussed innovators- opinion leaders- and mar.docx
In consumer behavior we discussed innovators- opinion leaders- and mar.docxIn consumer behavior we discussed innovators- opinion leaders- and mar.docx
In consumer behavior we discussed innovators- opinion leaders- and mar.docxtristans3
 
In chapter 2- 5 objectives of memory management were discussed- In Cha.docx
In chapter 2- 5 objectives of memory management were discussed- In Cha.docxIn chapter 2- 5 objectives of memory management were discussed- In Cha.docx
In chapter 2- 5 objectives of memory management were discussed- In Cha.docxtristans3
 
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docx
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docxIn certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docx
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docxtristans3
 
In c- Topic pointers Why do they call it dereferencing- As in derefer.docx
In c- Topic pointers  Why do they call it dereferencing- As in derefer.docxIn c- Topic pointers  Why do they call it dereferencing- As in derefer.docx
In c- Topic pointers Why do they call it dereferencing- As in derefer.docxtristans3
 
In C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docxIn C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docxtristans3
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxtristans3
 
In an alternative universe- all rules governing quantum numbers and th.docx
In an alternative universe- all rules governing quantum numbers and th.docxIn an alternative universe- all rules governing quantum numbers and th.docx
In an alternative universe- all rules governing quantum numbers and th.docxtristans3
 
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docx
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docxIn a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docx
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docxtristans3
 
In a Classical model of the macroeconomy- the equilibrating mechanism.docx
In a Classical model of the macroeconomy- the equilibrating mechanism.docxIn a Classical model of the macroeconomy- the equilibrating mechanism.docx
In a Classical model of the macroeconomy- the equilibrating mechanism.docxtristans3
 
In 2012- Shurtleff estimates that warranty costs in the following year.docx
In 2012- Shurtleff estimates that warranty costs in the following year.docxIn 2012- Shurtleff estimates that warranty costs in the following year.docx
In 2012- Shurtleff estimates that warranty costs in the following year.docxtristans3
 
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docx
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docxIn 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docx
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docxtristans3
 
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docx
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docxIn 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docx
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docxtristans3
 
Impulse and momentum are two two different parameters- Explain these p.docx
Impulse and momentum are two two different parameters- Explain these p.docxImpulse and momentum are two two different parameters- Explain these p.docx
Impulse and momentum are two two different parameters- Explain these p.docxtristans3
 
Implementation of EHR Discuss the advantages and disadvantages associa.docx
Implementation of EHR Discuss the advantages and disadvantages associa.docxImplementation of EHR Discuss the advantages and disadvantages associa.docx
Implementation of EHR Discuss the advantages and disadvantages associa.docxtristans3
 
Implementing a new AIS system could prove to be beneficial or detrimen.docx
Implementing a new AIS system could prove to be beneficial or detrimen.docxImplementing a new AIS system could prove to be beneficial or detrimen.docx
Implementing a new AIS system could prove to be beneficial or detrimen.docxtristans3
 
Im creating a stack class using generics- what should my peek method l.docx
Im creating a stack class using generics- what should my peek method l.docxIm creating a stack class using generics- what should my peek method l.docx
Im creating a stack class using generics- what should my peek method l.docxtristans3
 
ii)State whether you would expect the following Group 13 metal cations.docx
ii)State whether you would expect the following Group 13 metal cations.docxii)State whether you would expect the following Group 13 metal cations.docx
ii)State whether you would expect the following Group 13 metal cations.docxtristans3
 
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docx
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docxIMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docx
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docxtristans3
 
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docxtristans3
 

More from tristans3 (20)

In a symmetric multiprocessor configuration- AH processors can perform.docx
In a symmetric multiprocessor configuration- AH processors can perform.docxIn a symmetric multiprocessor configuration- AH processors can perform.docx
In a symmetric multiprocessor configuration- AH processors can perform.docx
 
In consumer behavior we discussed innovators- opinion leaders- and mar.docx
In consumer behavior we discussed innovators- opinion leaders- and mar.docxIn consumer behavior we discussed innovators- opinion leaders- and mar.docx
In consumer behavior we discussed innovators- opinion leaders- and mar.docx
 
In chapter 2- 5 objectives of memory management were discussed- In Cha.docx
In chapter 2- 5 objectives of memory management were discussed- In Cha.docxIn chapter 2- 5 objectives of memory management were discussed- In Cha.docx
In chapter 2- 5 objectives of memory management were discussed- In Cha.docx
 
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docx
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docxIn certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docx
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docx
 
In c- Topic pointers Why do they call it dereferencing- As in derefer.docx
In c- Topic pointers  Why do they call it dereferencing- As in derefer.docxIn c- Topic pointers  Why do they call it dereferencing- As in derefer.docx
In c- Topic pointers Why do they call it dereferencing- As in derefer.docx
 
In C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docxIn C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docx
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
 
In an alternative universe- all rules governing quantum numbers and th.docx
In an alternative universe- all rules governing quantum numbers and th.docxIn an alternative universe- all rules governing quantum numbers and th.docx
In an alternative universe- all rules governing quantum numbers and th.docx
 
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docx
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docxIn a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docx
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docx
 
In a Classical model of the macroeconomy- the equilibrating mechanism.docx
In a Classical model of the macroeconomy- the equilibrating mechanism.docxIn a Classical model of the macroeconomy- the equilibrating mechanism.docx
In a Classical model of the macroeconomy- the equilibrating mechanism.docx
 
In 2012- Shurtleff estimates that warranty costs in the following year.docx
In 2012- Shurtleff estimates that warranty costs in the following year.docxIn 2012- Shurtleff estimates that warranty costs in the following year.docx
In 2012- Shurtleff estimates that warranty costs in the following year.docx
 
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docx
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docxIn 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docx
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docx
 
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docx
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docxIn 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docx
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docx
 
Impulse and momentum are two two different parameters- Explain these p.docx
Impulse and momentum are two two different parameters- Explain these p.docxImpulse and momentum are two two different parameters- Explain these p.docx
Impulse and momentum are two two different parameters- Explain these p.docx
 
Implementation of EHR Discuss the advantages and disadvantages associa.docx
Implementation of EHR Discuss the advantages and disadvantages associa.docxImplementation of EHR Discuss the advantages and disadvantages associa.docx
Implementation of EHR Discuss the advantages and disadvantages associa.docx
 
Implementing a new AIS system could prove to be beneficial or detrimen.docx
Implementing a new AIS system could prove to be beneficial or detrimen.docxImplementing a new AIS system could prove to be beneficial or detrimen.docx
Implementing a new AIS system could prove to be beneficial or detrimen.docx
 
Im creating a stack class using generics- what should my peek method l.docx
Im creating a stack class using generics- what should my peek method l.docxIm creating a stack class using generics- what should my peek method l.docx
Im creating a stack class using generics- what should my peek method l.docx
 
ii)State whether you would expect the following Group 13 metal cations.docx
ii)State whether you would expect the following Group 13 metal cations.docxii)State whether you would expect the following Group 13 metal cations.docx
ii)State whether you would expect the following Group 13 metal cations.docx
 
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docx
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docxIMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docx
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docx
 
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx
 

Recently uploaded

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

Implement a method named letter that accepts a lowercase String of 2 l.docx

  • 1. Implement a method named letter that accepts a lowercase String of 2 letters. The method will return the letter that is midway between them. Example: if the String is "am" the return would be g (which is the letter midway between a and m). Solution /* java code to find middle character between two character */ import java.util.*; import java.util.Scanner; public class Midway { public static char mid(char start, char end) { int s = (int)start; int e = (int)end; int ascii = (s+e)/2; char character = (char)ascii; return character; } public static void main(String[] args) { // input string Scanner sc=new Scanner(System.in); System.out.print("Enter lowecase string of 2 letters: "); String letters = sc.next(); // determining the two characters char start = letters.charAt(0); char end = letters.charAt(1);
  • 2. if((int)start == (int)end) System.out.println("Both characters aree Equal No middle character found "); else if((int)start+1 == (int)end || (int)end+1 == (int)start ) System.out.println("No middle character found "); else { char middle_character = mid(start,end); System.out.println("Middle character is " + middle_character + " "); } } } /* Output : Enter lowecase string of 2 letters: aa Both characters aree Equal No middle character found Enter lowecase string of 2 letters: ab No middle character found Enter lowecase string of 2 letters: ba No middle character found Enter lowecase string of 2 letters: ac Middle character is b Enter lowecase string of 2 letters: am Middle character is g */