Write a Java program to do the following with your name. This can all be done in the main() method.
1. Create a String variable called myName and assign your personal name to it. Use proper capitalization for a legal name. I.e. String myName = "Billy Bob";
2. Load myName with the upper case version of itself and display the result.
3. Load myName with the lower case version of itself and display the result.
4. Capitalize the first letter of each given name in the lowercased name and display the result. Load the result into myName. Hint: This is not a single method call. You will need a loop to perform this. Hint: The substring method will be very helpful as you should likely build a new string result. Avoid magic number references. This solution should work with any proper name.
5. Using the value of the variable myName from Step 4:
public class Main
{
public static void main (String[]args)
{
String myName="Billy Bob";
myName=myName.toUpperCase();//toUpperCase converts into
capital
System.out.println(myName);
myName=myName.toLowerCase();//converts lower case
System.out.println(myName);
int i;
int ch,ch1;
for(i=0;i<myName.length()-1;i++)//parse through String
{
ch=myName.charAt(i);//store present Character
if(i==0)//for first we have to make it capital
{
ch=ch-32;//-32 will convert into capital
myName=(char)ch+myName.substring(1); //append converted capital and
remaining String
}
if(ch==' ')//if the Character is ' ' next one should be
capital
{
ch1=myName.charAt(i+1)-32;//convert next Character into upper
case
//append upto that Character and add converted upper case and
remaining
myName=myName.substring(0,i+1)+(char)ch1+myName.substring(i+2);
}
}
System.out.println(myName);
//first Character is always capital print that first
Character
System.out.print("The first letters of all names
are:"+myName.charAt(0)+" ");
for(i=1;i<myName.length()-1;i++)//parse through remaining
string
{
ch=myName.charAt(i);
if(ch==' ')//if the Character is ' ' then next Character is
definetly capital
System.out.print(myName.charAt(i+1)+" ");//print next
character
}
myName=myName.trim();
System.out.println("\nThe size of string "+myName+" is
"+myName.length());
}
}

Different input

Write a Java program to do the following with your name. This can all be done...
write a java program that does the following Part one Use a For loop to compute the sum of all the odd numbers from 1 through 99. Your result should be labeled, and the value should be 2500. Print your name 7 times using a While loop. String dogNames[ ] = {"Sam","Buster","Fido","Patches","Gromit","Flicka"}; Using the array defined here, print the values of the array vertically and horizontally using one For-Each loop. Reverse the logic (Nested loops: Indent text) so that the...
Write a Java program to meet the following requirements: 1. Prompt the user to enter three strings by using nextLine(). Space can be part of the string). ( Note: your program requires using loop: for-loop, while-loop or do-while-loop to get the input String ) 2. Write a method with an input variable (string type).The method should return the number of lowercase letters of the input variable. 3. Get the number of the lowercase letters for each user input string by...
Write a Java Program that performs the following functionalities: and you can use if statements, cases, and string methods Enter a new main sentence Find a String Find all incidents of a String Find and Replace a String Replace all the incidents of a String Count the number of words Count a letter’s occurrences Count the total number of letters Delete all the occurrences of a word Exit The program will display a menu with each option above, and then...
Java Write a Simple Program This question is about following the directions below. Failure to do so, results in lost credit. Write the definition of a method that takes in an integer number, and returns true if the number is prime, otherwise, returns false. A prime number is only divisible by itself and 1. Do not write the code for main here. The code must follow these steps in the order shown: 1. Name the method isPrime, and make it...
Write a working C program that will do the following: 1. Include your name, Lab Test number, and student id as comments in the first lines of the program 2. User is first prompted to enter an integer number between 1 and 20, to be stored as variable named number. If the number is outside the range 1-20, the program will end. 3. If the number is within the allowed range, variable number is passed to function multF(). The multF()...
Write a working C program that will do the following: 1. Include your name, Lab Test number, and studentId as comments in the first lines of the program 2. User is first prompted to enter an integer number between 1 and 20, to be stored as variable named number. If the number is outside the range 1-20, the program will end. 3. If the number is within the allowed range, variable number is passed to function multF(). The multF() function...
Prelab Exercises Your task is to write a Java program that will print out the following message (including the row of equal marks): Computer Science, Yes!!!! ========================= An outline of the program is below. Complete it as follows: a. In the documentation at the top, fill in the name of the file the program would be saved in and a brief description of what the program does. b. Add the code for the main method to do the printing. //...
**IN JAVAAssignment 10.1 [95 points]The WordCruncher classWrite the Java code for the class WordCruncher. Include the following members:A default constructor that sets the instance variable 'word' to the string "default".A parameterized constructor that accepts one String object as a parameter and stores it in the instance variable. The String must consist only of letters: no whitespace, digits, or punctuation. If the String parameter does not consist only of letters, set the instance variable to "default" instead. (This restriction will make...
( Object array + input) Write a Java program to meet the following requirements: 1. Define a class called Student which contains: 1.1 data fields: a. An integer data field contains student id b. Two String data fields named firstname and lastname c. A String data field contains student’s email address 1.2 methods: a. A no-arg constructor that will create a default student object. b. A constructor that creates a student with the specified student id, firstname, lastname and email_address...