String[] letters={"GHI","VWX","YZ&", 'JKL","MNO","ABC","STO","DEF","PQR"}; int n = 0; for (int i = letters.length-3; i > 0; i--) { System.out.printf("%s\n", letters[i].charAt (n++)) ; if(n > 2) n = 0; int[] array = {12,9,1,2,11,8,10,7,3}; System.out.println(array[array[3]-array[2]]*4);
Q: Look at the following array definition: String[] colors = {"Blue","Green","Purple"}; What will be…
A: Given data: String[] colors={"Blue", "Green", "Purple"}; Given problem: colors[2].length()…
Q: It is an array of references to string objects.a. string arrayb. character arrayc. ragged arrayd.…
A: Given: It is an array of references to string objects.a. string arrayb. character arrayc. ragged…
Q: Unfair hurdles are hurdles which are either too high, or way too close together. Create a function…
A: In this problem, we need to design the code in the Python programming language. Input - Array of…
Q: Unfair hurdles are hurdles which are either too high, or way too close together. Create a function…
A: As the programming language is not mentioned here, we are using PYTHON The code is given below with…
Q: Unfair hurdles are hurdles which are either too high, or way too close together. Create a function…
A: The answer is given in the below step
Q: python
A: Given :- A contact list is a place where you can store a specific contact with other associated…
Q: Initialize a string of size 40. Write a program that prints all unique alphabets from string. After…
A: Actually, string is a sequence of characters.
Q: int getLowestFromArray(int myList[], int size) int i; int lowestIndex = 0; for (i 1; i myList[i])…
A: In the given code, cData is a multidimensional array. It contains two lists {12, 5, 4, 7 ,8} and {6,…
Q: Unfair hurdles are hurdles which are either too high, or way too close together. Create a function…
A: I give the code in Python along with output and code screenshot
Q: Band matrices. Write a program BandMatrix.java that takes two integer command-line arguments n and…
A: Program approach: Created class BandMatrix. Create the main method. use command-line argument…
Q: Consider this program segment. You may assume that wordList has been declared as ArrayList.…
A: Given: To choose the correct option.
Q: Multiple choice in data structures string T="your name"; listL; to insert your name reversely in L…
A: This is correct because when for loop runs from i=0 to 'size -1' by satisfying the conditions, the…
Q: Capital Quiz Write a program that creates a map containing the U.S. states as keys, and their…
A: Given:
Q: *please help in java* Array testGrades contains NUM_VALS test scores. Write a for loop that sets…
A: Step 1 : assign sumExtra = 0 Step 2 : Make for loop till testGrades.length Step 3 : check for values…
Q: Code: public class RURottenTomatoes { public static void main (String[] args) { int r =…
A: Actually your code ia not wrong but some places their are some implementations problems I have fixed…
Q: void aSort (string arrl], int length}{ int j= 0; string temp = arr[0]; for (int i = 1; i= 0 && temp…
A: Sorting Algorithm: A Sorting Algorithm rearranges the members of an array or list based on a…
Q: Q2) Write a method that counts the occurrences of each capital character in a string. The method…
A: public class CountUpper { public static void main(String[] args) { String str =…
Q: ode (see chart) of the 11 letters found in the word, paired up with the number of times that letter…
A: Q. Prompt for a specific uppercase letter in the string to test. Re-prompt if a valid letter is…
Q: (b) #include int main() { int a, b; a = -3 -- 3; b = -3 -- (-3); printf ( "a = %d b = %d\n", a, b )…
A: The code is having following errors which are listed below:
Q: String creation with the contents of a string array - String creation(String al) JAVA a[]={…
A: We have to write a code in JAVA for String creation with the contents of a string array
Q: We have the following structures. sizeof(struct rec_s) = ; sizeof(rec_u) = struct rec_s{ char a;…
A: To do: Based on the given
Q: Write a program that will help a Little League coach keep track of the players on the team. Use an…
A: Use an infinite loop to display various options and specify a condition to quit from loop when user…
Q: int index0f (const string& s1, const string& s2)
A: Program: // C++ Version 114#include <iostream>#include <string> using namespace std; //…
Q: The __str__ method of the Bank class (in bank.py) returns a string containing the accounts in random…
A: According to the information given:- we have to create a Bank class with accountdesign…
Q: The __str__ method of the Bank class (in bank.py) returns a string containing the accounts in random…
A: Solution: Python code: """File: bank.pyThis module defines the Bank class.""" class…
Q: public static int] dateToArray(String date) - Converts a date in a String to an int], and returns…
A: method for above : public static int[] dateToArray(String date) { String[] temp =…
Q: Read your student number on the command line when you call the program executab Example: testq1.exe…
A: It is defined as the mother language of all the modern programming languages because most of the…
Q: 4. (Occurrences of each digit in a string) Write a method that counts the occurrences of each digit…
A: <?php // PHP program to count //number of digits of a given // character // Function that…
Q: d) public static String getMonthName(int month) { // return the month name for month // e.g. if…
A: Ans d: Code: public static String getMonthName(int month){ switch(month){ case 1:…
Q: **I1.18 (ArrayList of Character) Write a method that returns an array list of Charac- ter from a…
A: We need to write a java program that converts String to an Arraylist of characters. We need to write…
Q: Jehoout print (wholesCiJ* fracrfrachonlength-2] Assume the String array called words has been…
A: syntax of for-each loop:- for(type var : array) { statements using var } logic used:- iterate for…
Q: Write a program that first takes in word pairs that consist of a name and a phone number (both…
A: function main: Start read details make a list out of details initialize name with last element in…
Q: Unfair hurdles are hurdles which are either too high, or way too close together. Create a function…
A: Algorithm - Take input from user. Now use the below logic - let isTooTall = arr.length > 3;…
Q: C Programming: Write a program that reads a list of words. Then, the program outputs those words…
A: #include <stdio.h>#include <string.h> void main(){int cnt = 0, c = 0, i, j = 0, k, space…
Q: Unfair hurdles are hurdles which are either too high, or way too close together. Create a function…
A: In this problem, we need to design the code in the Python programming language. Input - Array of…
Q: Given an array that contains names of some colors, write a program that picks a color randomly from…
A: Given: An array that contains names of some colors, string colors[] = {“Green”, “Blue”, “Red”,…
Q: convert this code to JAVA location = [] size = [] rover = 0 def displayInitialList(location,…
A: Dear Student,There were details missing in the code like The methods allocateMemory() and…
Q: A contact list is a place where you can store a specific contact with other associated information…
A: Method: 1 In this method, we will take the list from the user and convert it to a dictionary using…
Q: Write a program that prompts the user to input a string and outputs the string in uppercase letters…
A: C++ code
Q: lic MyString(char[] chars); lic char charAt(int index); plic int length(); lic MyString…
A: We need to MyString class as per the given methods interfaces.
Q: (Game: pick four cards) Write a program which creates a deck of cards of 52 and pick any four cards…
A: As Language is not defined I'm doing it in Java Language
Q: class Main { // this function will return the number elements in the given range…
A: In the getArrayElemsInRange() method – Take an array to store the numbers of the range. Use a loop…
Q: File Welcome to OOPII PizzaMania Each Topping: $150 Pizza Size Pizza Type Tomato O Small: $25.00 O…
A: The java code is
Q: Write code that creates an array of 9 string elements and initialises them to empty.
A: Program code: //main class public class Main { //main method public static void…
Q: Design a program that allows the user to enter 20 names into a String array. Sort the array in…
A: Please refer below code and output screenshot: Language used is C++: #include…
Q: Write a program in C++ programming language that: I. records the basic information of a patient…
A: #include <iostream>using namespace std;//method to conver Fahrenheit to celsiusvoid…
Q: Unfair hurdles are hurdles which are either too high, or way too close together. Create a function…
A: I give the code in Python along with output and code screenshot
Q: POEM_LINE = str POEM = List[POEM_LINE] PHONEMES = Tuple[str] PRONUNCIATION_DICT = Dict[str,…
A: Task : The task is to check all rhymes : given in the poem lines at given indexes.
Q: Write a function that takes a string and calculates the number of letters and digits within it.…
A: In this problem we need to design the pHP program. Input - String Ouput - Array
Q: Unfair hurdles are hurdles which are either too high, or way too close together. Create a function…
A: Since the programming language is not mentioned , I have done the code using JavaScript.
Trace the following pieces of code and give their exact output and the tracing steps.
Step by step
Solved in 2 steps with 7 images
- 1. Given a string of at least 3 characters as input, if the length of the string is odd return the character in the middle as a string. If the string is even return the two characters at the midpoint. public class Class1 { public static String midString(String str) { //Enter code here } } ----------- 2. Given an array of integers return the sum of the values stored in the first and last index of the array. The array will have at least 2 elements in it public class Class1 { public static int endSum(int[] values) { //Enter code here } } ----------- 3. The method takes a string as a parameter. The method prints treat if the string is candy or chocolate (of any case, such as CaNdY) Otherwise print trick import java.util.Scanner; public class Class1 { public static void trickOrTreat(String str) { //Enter code here } public static void main(String[] args) { Scanner s = new Scanner(System.in); trickOrTreat(s.nextLine()); } }For any element in keysList with a value smaller than 40, print the corresponding value in itemsList, followed by a comma (no spaces). Ex: If keysList = {32, 105, 101, 35} and itemsList = {10, 20, 30, 40}, print: 10,40, #include <iostream>#include <string.h>using namespace std; int main() { const int SIZE_LIST = 4; int keysList[SIZE_LIST]; int itemsList[SIZE_LIST]; int i; cin >> keysList[0]; cin >> keysList[1]; cin >> keysList[2]; cin >> keysList[3]; cin >> itemsList[0]; cin >> itemsList[1]; cin >> itemsList[2]; cin >> itemsList[3]; /* Your code goes here */ cout << endl; return 0;}For any element in keysList with a value smaller than 40, print the corresponding value in itemsList, followed by a space. Ex: If keysList = {32, 105, 101, 35} and itemsList = {10, 20, 30, 40}, print: 10 40 #include <iostream>#include <string.h>using namespace std; int main() { const int SIZE_LIST = 4; int keysList[SIZE_LIST]; int itemsList[SIZE_LIST]; int i; cin >> keysList[0]; cin >> keysList[1]; cin >> keysList[2]; cin >> keysList[3]; cin >> itemsList[0]; cin >> itemsList[1]; cin >> itemsList[2]; cin >> itemsList[3]; /* Your code goes here */ cout << endl; return 0;}
- Variables Primitive Write a java program that asks the user to enter 3 integers. Add the integers and display “The total is “ the result Reference Write a java program that asks the user for their first name and last name. Display “Your full name is “ the first name and last name Arrays One-dimensional Write a java program that creates an array of integers called numbers and contains five elements. Then use a for loop to print them out using println(). Two-dimensional submit your code for the total of rows and total of columns hereCan help in java String [] names = {"Dimo Ivanov", "Yani Yanev", "Ana Popova", "Nelly Angelova"}; 1. Display the array in the console using the Arrays.toString () method 2. Display the names and the number of characters in the name (without the space) as a table (use printf) Name Number of lettersDimo Ivanov 10 3. Get an array first_letters of type char [], containing the first letters of the names. Display it with Arrays.toString () 4. Get the arrays of names and surnames containing initial and second names, respectively (first determine the position of the space in the previous name with the indexOf () method of the String class). Display the arrays. 5. Sort the first_names arrayin c# Write a console app that inputs a sentence from the user (assume no punctuation), then determines and displays ONLY THE DUPLICATE words in alphabetical order. Treat uppercase and lowercase letters the same. [Hint: You can use string method Split with no arguments, as in sentence.Split(), to break a sentence into an array of strings containing the individual words. By default, Split uses spaces as delimiters. Use string method ToLower before calling Split.]
- void showArray ( int a[ ], int size ); // shows the array in the format "int a [ ] = { 3, 7, 4, ... ,5, 6, 3} void showReverse ( int a[ ], int size ); // shows the array in reverse "int a [ ] = { 3, 6, 5, ... , 4, 7, 3 } " int lowest ( int a[ ], int size ); // finds and returns the lowest value in the array (should be 3) int highest ( int a[ ], int size ); // finds and returns the highest value in the array (should be 7) int sumArray ( int a[ ], int size ); // calculates and returns the sum of all values in the array float averageVal ( int a[ ], int size ); // calculates and returns the average of all values in the array int count5 ( int a[ ], int size ); // returns how many times the number 5 appears in the array int firstMinusLast ( int a[ ], int size ); // returns the difference b/w the First and Last Array Element void showBeforeIndex( int a [ ], int index); // shows all array values before a specific index void done…javascript only: Write a function `popularLetters(string)` that takes a string as an argument and returns an array of all of the characters that appear five or more times in the string. Examples: console.log(popularLetters('apple')); // [] console.log(popularLetters('bananas in pajamas')); // [ 'a' ] console.log(popularLetters('Yes, we have no bananas, we have no bananas today!')); // [ 'e', ' ', 'a', 'n' ]Visual Basic.net) Write a Code that defines one dimensional arrays of ten elements that sums the even numbers from them and a counter that counts how many elements is an even number and comes out from the Loop when the sum of the even values becomes greater than 30 and the counter for these values is greater than 4. Write a program in Visual Basic.net .
- def small_index(items: list[int]) -> int:"""Return the index of the first integer in items that is less than its index,or -1 if no such integer exists in items.>>> small_index([2, 5, 7, 99, 6])-1>>> small_index([-5, 8, 9, 16])0>>> small_index([5, 8, 9, 0, 1, 3])3"""5.17 LAB: Word frequencies (JAVA) Write a program in java that reads a list of words. Then, the program outputs those words and their frequencies. The input begins with an integer indicating the number of words that follow. Assume that the list will always contain fewer than 20 words. Ex: If the input is: 5 hey hi Mark hi mark the output is: hey - 1 hi - 2 Mark - 1 hi - 2 mark - 1 Hint: Use two arrays, one array for the strings and one array for the frequencies.class Main { // this function will return the number elements in the given range public static int getCountInRange(int[] array, int lower, int upper) { int count = 0; // to count the numbers // this loop will count the numbers in the range for (int i = 0; i < array.length; i++) { // if element is in the range if (array[i] >= lower && array[i] <= upper) count++; } return count; } public static void main(String[] args) { // array int array[] = {1,2,3,4,5,6,7,8,9,0}; // ower and upper range int lower = 1, upper = 9; // throwing an exception…