Write a method called upper that takes a lowercase character as a parameter and converts the character to uppercase and returns it without using String's toUpperCase() method. public char upper(char lowerChar){
Write in JAVA
Answer in step2
#Source_code
/******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
import java.util.*;
public class Main
{
public char upper(char lowerChar){
char ch=(char)(lowerChar-32);
return ch;
}
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("enter a lower case character:");
char lowerChar=sc.next().charAt(0);
Main obj = new Main();
System.out.println("upper character will be:" + obj.upper(lowerChar));
}
}
Step by step
Solved in 3 steps with 1 images