Question

In: Computer Science

In a Package called characterArray, ********JAVA CODE********** 1) Create a char array containing your full name...

In a Package called characterArray, ********JAVA CODE**********
1) Create a char array containing your full name and print it out.
2) Create an uninitialized char array and copy into it
     the char array containing your full name and print it out.
3) Create a Character array and copy into it the char array containing
     your full name and print it out.
4) Into the Character array, use toUpperCase() to copy the char array containing
    your full name and print it out.
5) Convert the Characters in place using toLowerCase() and charValue()
     to lowercase Characters.

Solutions

Expert Solution

thanks for the question, here is the code in Java, when you run the program please update the char array with yoru full name.

Comments given for you to identify the code for each sub parts

========================================================================

public class CharArray {

    public static void main(String[] args) {

        // 1. Create a char array containing your full name
        System.out.println("Part 1");
        char name[] = {'B', 'a', 'r', 'a', 'c', 'k', ' ', 'O', 'b', 'a', 'm', 'a'};
        // print it out
        for (int i = 0; i < name.length; i++) {
            System.out.printf("%c", name[i]);
        }
        System.out.println("\n\nPart 2");

        // 2 Create an unitialized char array and copy into it
        char duplicate[] = new char[name.length];
        for (int i = 0; i < name.length; i++) duplicate[i] = name[i];
        // print it out
        for (int i = 0; i < name.length; i++) {
            System.out.printf("%c", duplicate[i]);
        }
        System.out.println("\n\nPart 3");

        //3. Create a Character array
        Character duplicateObject[] = new Character[name.length];
        for (int i = 0; i < name.length; i++) duplicateObject[i] = new Character(name[i]);
        // print it out
        for (int i = 0; i < name.length; i++) {
            System.out.printf("%c", duplicateObject[i]);
      }
        System.out.println("\n\nPart 4");


        //5. use to UpperCase to copy the char array
        for (int i = 0; i < name.length; i++) duplicateObject[i] = Character.toUpperCase(duplicateObject[i]);
        for (int i = 0; i < name.length; i++) {
            System.out.printf("%c", duplicateObject[i]);
        }
        System.out.println("\n\nPart 5");

        // 6. Convert the characters to lower case using tolowercae and charvalue
        for (int i = 0; i < name.length; i++)
           duplicateObject[i] = Character.toLowerCase(duplicateObject[i]);
        for (int i = 0; i < name.length; i++) {
            System.out.printf("%c", duplicateObject[i].charValue());
        }

    }
}

====================================================================


Related Solutions

In STS, create Java Project, called java_generics_yourNameLastname that; (Under source directory called, src, create a package...
In STS, create Java Project, called java_generics_yourNameLastname that; (Under source directory called, src, create a package csci3444.generics and put all code in it) Create a generic interface called “MyGenInterface” that takes 2 generic types K,V with below methods; public K getKey(); public V getValue(); Create a generic class called “MyGenClass” that implements “MyGenInterface” interface. has attributes “K key” and “V value” that can be inherited has a constructor that takes “K _key”, “V _value” inputs and initializes “key”, “value” attributes...
You need a data structure that contains fields for name (char array), color (char array), age...
You need a data structure that contains fields for name (char array), color (char array), age (int), and height (int). Name the struct Info when you define it. Create a function named getUserInfo() that asks the user for name, color, age, and height and then returns a data structure containing that information. It should do the following: What is your name? George What is your favorite color? Green What is your age? 111 What is your height in inches? 72...
JAVA CODE Give the definition of a static method called showArray that has an array of...
JAVA CODE Give the definition of a static method called showArray that has an array of base type char as a single parameter and that writes to the screen each character in the array on a separate line. It then writes the same array characters in reverse order. This method returns a character array that holds these two lines of characters in the order that you printed them.
1.Write the java code to create a two dimensional String array of sizes 12 by 8;...
1.Write the java code to create a two dimensional String array of sizes 12 by 8; Given the java array:       double[] test = new double[3]; 2.  Write the java code to put the numbers 1.0, 2.0, and 3.0 in to the array so that the 1.0 goes in the first cell, the 2.0 goes in the second cell and the 3.0 goes in the third cell. 3. Can you have different types of data is a three dimensional array? 4....
Create a structure in C called BarcelonaPlayer with the following members. struct BarcelonaPlayer { char name[20];...
Create a structure in C called BarcelonaPlayer with the following members. struct BarcelonaPlayer { char name[20]; int age; char country[20]; char Position[20]; double Salary; double Rating; }; First, create an array of BarcelonaPlayer structures. Now, write a function that takes an array of BarcelonaPlayer structures as input and find out the highest paid player among all the players. void highestPaidPlayer(struct BarcelonaPlayer *pl, int size); Create another function that finds all the players from Argentina. void findPlayers(struct BarcelonaPlayer *pl, int size);
Create a Word file containing the following: The full name of the “test subject” The test...
Create a Word file containing the following: The full name of the “test subject” The test subject is a person, not yourself, who can say the names of the products. The best test subject is one who is adamant about being an expert who can distinguish brand A from B. You cannot be the test subject because you generate the sequence, and the test subject cannot see it for an unbiased test. Pets and babies are not allowed as they...
Part 1: Create a character array and save your first and last name in it
PROGRAMMING IN C:Part 1:Create a character array and save your first and last name in itNote: You can assign the name directly or you can use the scanf function.Display your name on the screen.Display the address (memory location) in hexadecimal notation of the array. (hint: use %p)Use a for loop to display each letter of your name on a separate line.Part 2:Create a one dimensional array and initialize it with 10 integers of your choice.Create a function and pass the...
java code: Problem 1: Create a class called Elevator that can be moved between floors in...
java code: Problem 1: Create a class called Elevator that can be moved between floors in an N-storey building. Elevator uses a constructor to initialize the number of floors (N) in the building when the object is instantiated. Elevator also has a default constructor that creates a five storey building. The Elevator class has a termination condition that requires the elevator to be moved to the main (i.e., first) floor when the object is cleaned up. Write a finalize() method...
Code in Java 1. Create a class Flower with data: Name, Price, Color and properly methods....
Code in Java 1. Create a class Flower with data: Name, Price, Color and properly methods. 2. Create another class named ListFlower. This class manages a collection of Flower (may be LinkedList) named a. Implementing some methods for ListFlower: Add: add new item of Flower to a Display: display all items of a sort(): sort as descending by Price and display all items of a search(Flower f): check and return whether f is exists in a or not. delete(int pos):...
IN SQL Create a table called product containing a product no, company name, model_no,product name. What...
IN SQL Create a table called product containing a product no, company name, model_no,product name. What is my primary key? Which datatypes should I use?Pleasesubmit a printout of the commands used for creating the above table and the resultsof your queries/commands
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT