s[0]=7;s[1]=0;s[2]=-12;s[3]=9;s[4]=10;s[5]=3;s[6]=6; the value of [s[6-s[5]]is:
Q: Extract the city name and state from strings like “Utica, NY” and “Los Angeles, CA”. Assume the…
A: Code: As no coding language is mentioned providing the code in JAVA: import…
Q: java.lang.StringBuilder uses a resizing array to represent a string of length n, with the first…
A: StringBuilder will build the empty string Append function append char at the end of string. prepend…
Q: Create a java program that generates elements (randomly from 10 – 75) of a 2-dimensional array (5x5)…
A: The program is written in Java. Please find the program and output in the following steps.
Q: JAVA program Write a Java program that asks the user to enter an array of integers. The program…
A: The array is a homogenous collection of elements that are stored in consecutive memory locations.…
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: Lab Goal : This lab was designed to teach you more about sorting data with the built-in java sorts.…
A: Answer
Q: Allow the user to enter 10 numbers, sort and display the list in ascending and descending order.…
A: Here I have used bubble sort to sort the array. Algorithm : sortAsc function : Step 1 : declare…
Q: A spell checker in a word processing program makes suggestions when it finds a word not in the…
A: Spell Checker: A spell checker in a word processing program gives a suggestions when we write a…
Q: (Count single digits) Write a program that generates 100 random integers between O and 9 and…
A: Java used to answer this question
Q: Write a java console application that generates 10 random numbers between 1-10 Store these numbers…
A: Here we need to use the random class provided by java to generate random number. Let's define array…
Q: Computer Science Java Program Write a program in Java that takes in a user-submitted file that is a…
A: Given Computer Science Java Program Write a program in Java that takes in a user-submitted…
Q: Capital Quiz Write a program that creates a map containing the U.S. states as keys, and their…
A: Given:
Q: TRUE or FALSE IN JAVA You can obtain the number of rows using Array.length, and the number of…
A: Java allows to store the tabular data into 2D array. A 2D array is an array whose elements are store…
Q: Write a C# application that populates an array with 10 items and prints all N multiples. Where N is…
A: Use a loop to iterate for 10 times and input the element then iterate over the array again and check…
Q: b. 2 balloons 2 balloons Hence, r is only the balloon which is odd in number. Example 2: Input: ● y:…
A: Answer: Algorithms Step1:we have taken user input as the size of the string Step2: Then we have ask…
Q: An array of short numbers [] is given, and integers are written in the array. Your task is to…
A: The element is defined as the distance between elements by the first element of the same members…
Q: : A turtle object (which will do the drawing) polygon_points: A list of (x, y) points (i.e. a list…
A: We need to define the draw_subregion() function as per the given description.
Q: Variable t has been assigned a tuple whose elements are numbers. Write a code that uses while loop…
A: According to the information given:- We have to write a code that uses while loop that counts the…
Q: PART 2. STRINGS Implement a program that reads two strings from the user and merges them into a new…
A: Here i have written string concatenation without using string.h
Q: Write a program that creates a list of planets and their distance from the sun. c++ bring a brief…
A: CODE: #include<iostream> #include<iterator> #include<map> using namespace std; {…
Q: Write a JavaSeript function that performs the following: 1. Define Color Array contains any five…
A: - With our restricted guidelines, we are allowed to answer the first question only.
Q: P1 P2 P3 P4 A pentagonal number is one that corresponds to dots arranged into a pentagon. Above are…
A: Solution :: The solution for finding pentagon number is to find using recursion, as to calculate…
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: Small monster scientists do a great deal of work to analyze small monster migratory and feeding…
A: Given The answer is given below.
Q: Java programming Problem-3 There are two sorted arrays A and B. First one is of size m + n…
A: PROGRAM: //Creating a class with the name of Merger class MergeArrays { //Defining the method…
Q: In C Programming Language Palindrome: “A palindrome is a word, phrase, number, or other sequence of…
A: #include <stdio.h>#include <stdlib.h> // For exit() function //function for storing the…
Q: Suppose you are given an array of integers. You want to insert a number x to the array and rearrange…
A: Basically, an input array is taken and an element has to be inserted into it, in such a way that all…
Q: Visual Basic.net) Write a Code that defines one dimensional arrays of ten elements that sums the…
A:
Q: Write a method that rotates N number of 2-D points by given angle (counter-clockwise). The points…
A: The formula to rotate a point by a given angle is :
Q: def odd average (t: Tree) -> float: ||||| Return the average of the odd values in t, 0 if none are…
A: Given a Tree class, we need to implement odd_average() method which takes the root of the tree as an…
Q: 0 is an element {{0},{1}}
A: Given representation denotes a two dimensional array and a two dimensional array is a data structure…
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: Write in C language not Java Description Give you a 2-D array represent a maze, in this maze, 1 is…
A: Objective: This program reads the size of the maze and prints "yes" if there is any solution. If…
Q: Add a while loop to the BMI prcoedure below.
A: The given is a snippet of Python code where a function BMIImperial takes some parameters and print…
Q: Write a Java program that asks the user to enter an array of integers. The program should prompt the…
A: If Array Size is less than 2 Return 0 Else Initialize min as difference of first two…
Q: Create a function that returns the frequency distribution of an array. This function should return…
A: Algorithm - Take input from user. Now use the below logic - for (let el of arr) { if (out[el])…
Q: Question: Write a program to Simulate a game of tic tac toe. A game of tic tac toe has two players.…
A: Program.cs: using System; using System.Collections.Generic; using System.Linq; using System.Text;…
Q: Nrite a program in Java that reads 10 integers and store them in AN ArrayList. Then, do the…
A: Here I have first of all created an ArrayList with the size 10. Now I have used a for loop to…
Q: PROBLEM STATEMENT: In this problem you will need to insert 5 at the front of the provided ArrayList…
A: Required: PROBLEM STATEMENT: In this problem you will need to insert 5 at the front of the provided…
Q: Write a java program that finds the largest and smallest element in 2 dimension array
A: import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner…
Q: java Use Map data structure Write a method that returns the frequency of each characters of a…
A: The answer is given in the below step
Q: You have to use comment function to describe what each line does import java.io.BufferedReader;…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: create_equation(n, pct_per_digit): Takes one positive odd integer and one float in [0, 1[ as input.…
A: from blackout_utils import * import random random.seed(9001) OPERATIONS = ['^', 'x', '/', '+', '-']…
Q: In C++ language, write a program to print "Junior" if the given array element starts with 'J' and…
A: In C++ language, write a program to print "Junior" if the given array element starts with 'J' and…
Q: In Java Assignment 5B : Maze Game! 2D Arrays can be used to store and represent information about…
A: ANSWER:-
Q: (Plot the cube function) Write a program that draws a diagram for the functionf(x) = x3 (see Figure…
A: Create a Polyline in JavaFX To draw a polyline in JavaFX, first, write a class that derives the…
Q: Part 1: In Java Write a program that uses a 2-D array to store the highest and lowest temperatures…
A: Your solution is here with an Output.
Q: In computational geometry, often you need to find the rightmost lowest point in a set of points.…
A: Given program allow user to enter the coordinates of six points and display the rightmost lowest…
Q: Java Without using any java functions, data structures, libraries, string builder or anything…
A: The StringTokenizer classes in Java is used to tokenize a string. When taking a substring of both…
Q: Geometry: area of a pentagon) Write a program that prompts the user to enter the length from the…
A: Declare double type variables to store side and area of pentagon. Read distance from centre to…
s[0]=7;s[1]=0;s[2]=-12;s[3]=9;s[4]=10;s[5]=3;s[6]=6; the value of [s[6-s[5]]is:
s[6-s[5]] = 9
Step by step
Solved in 2 steps
- Transcribed Image Text JAVA Programming Problem: In the game of "Assassin's Creed", you control a ship with a cannon which is attacking a large enemy Assassin's Creed, armed with many guns. Your goal is to destroy as many of the guns as possible. The battle field is a 2D Cartesian grid, where your cannon is located at the origin. The enemy Assassin's Creed is a horizontal line segment located from the coordinates (X1, Y) to (X2, Y). There are exactly (X2 - X1 + 1) guns on the ship, located at the integer points (X1, Y), (X1+1, Y), ..., (X2, Y). However, the problem is, you cannot always fire at a gun. There are supernatural rocks located at all points of the battlefield whose X and Y coordinates are both integers. In order to fire successfully at an enemy's gun, the line connecting your cannon and that gun must not go through any rocks. Develop a JAVA code to output the number of the enemy battleship's guns that your cannon can destroy. Test Case Result 1 2 2 -2Knight's Tour: The Knight's Tour is a mathematical problem involving a knight on a chessboard. The knight is placed on the empty board and, moving according to the rules of chess, must visit each square exactly once. There are several billion solutions to the problem, of which about 122,000,000 have the knight finishing on the same square on which it begins. When this occurs the tour is said to be closed. Your assignment is to write a program that gives a solution to the Knight's Tour problem recursively. You must hand in a solution in C++ AND Java. The name of the C++ file should be "main.cc" and the name of the Java file should be "Main.java". Write C++ only with a file name of main.cc Please run in IDE and check to ensure that there are no errors occuring Output should look similar to: 1 34 3 18 49 32 13 16 4 19 56 33 14 17 50 31 57 2 35 48 55 52 15 12 20 5 60 53 36 47 30 51 41 58 37 46 61 54 11 26 6 21 42 59 38 27 64 29 43 40 23 8 45 62 25 10 22 7 44 39 24 9 28 63In visual basic Print out the last value in a single-dimensional array.
- Computer Science Java Program Write a program in Java that takes in a user-submitted file that is a grid of 0s and 1s. Represent the grid as a two-dimensional array. Write a program that: a. computes the size of a group when a square in the group is given b. computes the numbers of different groups c. lists all groups Example: userInput.txt: 0 0 0 0 0 0 0 0 0 10 0 0 1 1 0 0 0 0 10 0 0 0 0 0 0 0 0 00 0 0 0 1 0 0 1 0 00 0 0 1 0 0 0 1 0 00 0 0 0 0 0 0 1 1 00 0 0 0 1 1 0 0 0 00 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 The program should output three things: The size of the group in which location specified by the user belongs. then if the user enters 1,2 the answer is 0 1,4 the answer is 2 3,4 the answer is 1 4,7 the answer is 4 The number of each size group Size Count 2 3 1 List of each group’s locations 1: (0,9) (1,9) 2: (1,3) (1,4) 3: (3,4) 4: (3,7) (4,7) (5,7) (5,8) 5: (4,3) 6: (6,4) (6,5)A spell checker in a word processing program makes suggestions when it finds a word not in the dictionary. To determine what words to suggest, it tries to find similar words. One measure of word similarity is the Levenshtein distance, which measures the number of substitutions, additions, or deletions that are required to change one word into another. For example, the words spit and spot are a distance of 1 apart; changing spit to spot requires one substitution (i for o). Likewise, spit is distance 1 from pit since the change requires one deletion (the s). The word spite is also distance 1 from spit since it requires one addition (the e). The word soot is distance 2 from spit since two substitutions would be required. a. Create a graph using words as vertices, and edges connecting words with a Levenshtein distance of 1. Use the misspelled word “moke” as the center, and try to find at least 10 connected dictionary words. How might a spell checker use this graph? b. Improve the method…Write a program in Java programming language that reads an array of strings! The program should write all the strings from array that end with letter 'a'.
- Write a program in Java programming language that reads an array of strings!The program should write all the strings from array that have at least one letter 'a'.(Algebra: perfect square ) Write a program that prompts the user to enter an integer m and find the smallest integer n such that m * n is a perfect square. (Hint: Store all smallest factors of m into an array list. n is the product of the factors that appear an odd number of times in the array list. For example, consider m = 90, store the factors 2, 3, 3, 5 in an array list. 2 and 5 appear an odd number of times in the array list. So, n is 10.) Sample Run 1 Enter an integer m: 1500 The smallest number n for m x n to be a perfect square is 15 m x n is 22500 Sample Run 2 Enter an integer m: 63 The smallest number n for m x n to be a perfect square is 7 m x n is 441 Class Name: Exercise11_17 Answer is : import java.util.Scanner; public class Squares { public static void main(String[] args) { Scanner scan = new Scanner(System.in); //instantiation of Scanner that will take inputs from the keyboard //the try catch block below is for trapping error with the input try {…java Use Map data structure Write a method that returns the frequency of each characters of a given String parameters If the given String is null ,then return null
- using java programming int a[] = {5,10,4,20,1,7}; 1- search for the smallest element in array 2-if you found the smallest element in the array :swap the first element with the smallest elementVariables 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 hereLab Goal : This lab was designed to teach you more about sorting data with the built-in java sorts. Lab Description : Take a list of words and output the list in ascending order. Use Arrays.sort().Sample Data : abc ABC 12321 fred alexandera zebra friendly acrobatics 435 TONER PRinTeRb x 4 r s y $123 ABC abc 034 dog cat sally sue bob 2a2Sample Output : word 0 :: 12321word 1 :: ABCword 2 :: abcword 3 :: alexanderword 4 :: fred word 0 :: 435word 1 :: PRinTeRword 2 :: TONERword 3 :: aword 4 :: acrobaticsword 5 :: friendlyword 6 :: zebra word 0 :: $word 1 :: 4word 2 :: bword 3 :: rword 4 :: sword 5 :: xword 6 :: y word 0 :: 034word 1 :: 123word 2 :: 2a2word 3 :: ABCword 4 :: abcword 5 :: bobword 6 :: catword 7 :: dogword 8 :: sallyword 9 :: sue I need a code class and a runner class