Question

In: Computer Science

In Java Problem 1 Create an Array of your top four vacation spots. Print the first...

In Java

Problem 1
Create an Array of your top four vacation spots. Print the first spot and the last spot in your array.

Problem 2
Create an Array to hold the names of 5 people. Print the first letter of each of their names.

Problem 3
Create a mini console game that asks for the number of words you want to enter into an Array. Enter each word and then a letter. Print out feedback that says "Yep its got one of those" or "Sorry that letter is not in the word" depending on whether on not the word entered contains the letter specified.

Stretch Task (Optional)
Create a String representing a list of things that uses some delimiter (commas,dashes, etc) Split that String into an Array of Strings, then print each of the Array Elements. You will need to research (How to Split a String using a Delimiter).

Solutions

Expert Solution

Answer 1:

public class VacationSpot {
public static void main(String[] args) {
   // creating array with 4 places
   String arr[]={"Hyderebad","Chicago","Delhi","Kerala"};
   // printing the first spot
   System.out.println("First Spot : "+arr[0]);
   // printing the last spot
   System.out.println("Last Spot : "+arr[3]);
}
}

Answer 2:

public class NamesOfPeople {
   public static void main(String[] args) {
       // created array with 5 values
       String names[] = { "Uday", "Koti", "Smith", "Virat", "Chotu" };
       // iterating through the array
       for (String str : names) {
           // printing the first char of each name
           System.out.println(str + " : " + str.charAt(0));
       }

   }
}

Answer 3:

import java.util.Scanner;

public class WordsCheck {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       System.out.println("Enter number of words");
       int n = sc.nextInt();
       sc.nextLine();
       String words[] = new String[n];
       char c[] = new char[n];
       System.out.println("Enter " + n + " words ");
       for (int i = 0; i < n; i++) {
           words[i] = sc.nextLine();
           c[i] = sc.nextLine().charAt(0);
           if (words[i].contains(c[i] + "")) {
               System.out.println("Yep its got one of those");
           } else {
               System.out.println("Sorry that letter is not in the word");
           }
       }
   }
}


Related Solutions

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 Programming Problem 1: Reverse Characters Create an application ReverseCharacters in which you use an array-based...
java Programming Problem 1: Reverse Characters Create an application ReverseCharacters in which you use an array-based stack to read a sentence from the keyboard, and reverse the order of the letters in each word. Print the initial sentence, as well as the result of the reversal operation. Your Tasks: Using the information given in your textbook, create a class named ArrayBasedStack, that will help you solve the problem given above by providing the stack operations you need for this application....
Write a program in Java that initializes an array with ten random integers and then print...
Write a program in Java that initializes an array with ten random integers and then print three lines of output, containing: Every element at an odd index Every odd element All elements in reverse order   The program should use three different methods to implement the functionalities above. Call the primary source file ArrayManipulator.java
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...
in java Implement a function print2Darray(int[][] array) to print a formatted 4x4 two dimensional integer array....
in java Implement a function print2Darray(int[][] array) to print a formatted 4x4 two dimensional integer array. When the array contains {{10, 15, 30, 40},{15, 5, 8, 2}, {20, 2, 4, 2},{1, 4, 5, 0}}, Your output should look like: {10 15 30 40} {15 5 8 2}{ 20 2 4 2}{ 1450} Now, implement another function print2DList(ArrayList<ArrayList<Integer>> list) to print a formatted 2D list.
In JAVA Use a two-dimensional array to solve the following problem: A company has four salespeople...
In JAVA Use a two-dimensional array to solve the following problem: A company has four salespeople - Sales Person 1, Sales Person 2, Sales Person 3, and Sales Person 4. The company sells 5 products - Product 1, Product 2, Product 3, Product 4, and Product 5. Each day, a sales person hands in a slip with the following information: Sales Person Number (1,2,3, or 4), Product Number (1,2,3,4, or 5), and dollar value of that product sold. This dollar...
Problem Definition: Problem: Given an array of integers print all pairs of integers a and b...
Problem Definition: Problem: Given an array of integers print all pairs of integers a and b where a + b is equal to a given number. For example, consider the following array and suppose we want to find all pairs of integers a and b where a + b = 16 A= [ 10, 4, 6, 15, 3, 5, 1, 13] The following are pairs that sum to 16: 13, 3 6, 10 15, 1 Your program should print these...
Language: Java Question:Using your Circle class (or the one provided below), create a Circle array of...
Language: Java Question:Using your Circle class (or the one provided below), create a Circle array of size 4 in a driver class using the following statement: Circle circleArr[] = new Circle[4]; Populate the array with four different radiuses and then, using a for loop from 0 to one less then the length of the array, print the area and the diameter of each of the four circles Circle Class: import java.text.DecimalFormat; public class Circle {    DecimalFormat dec = new...
In C Create a multi-dimensional array and print it out forwards, backwards and then transpose.
In C Create a multi-dimensional array and print it out forwards, backwards and then transpose.
Create a generic method to print objects in java. Include a tester class.
Create a generic method to print objects in java. Include a tester class.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT