Exercise 3 - Distances Create a new class called Distances. In this class, implement a program that computes and outputs distances between all of the following points on a plane: (1,2), (3,5), (4,2), (2,9), (3,3). The points should be hard coded as a two-dimensional double array. Output should look like this: 0.00 3.61 3.00 7.07 2.24 3.61 0.00 3.16 4.12 2.00 3.00 3.16 0.00 7.28 1.41 7.07 4.12 7.28 0.00 6.08 2.24 2.00 1.41 6.08 0.00
Q: String [] names = {"Dimo Ivanov", "Yani Yanev", "Ana Popova", "Nelly Angelova"}; 1. Get the arrays…
A: String first_names[] = new String[names.length]; String last_names[] = new String[names.length];…
Q: In this task you must write a class with which we can roll five dice and then check if we have got…
A:
Q: How many pets do you have? 3 What is the name of your pet? Buttercup What type of pet is Buttercup?…
A: The answer is given below:-
Q: Write a function that converts an object into an array, where each element represents a key-value…
A: Please refer below code and output: Language used is JAVASCRIPT: function toArray(obj){ var…
Q: السؤال 23 C1. Write a Java program named Transform that generates a single-dimensional array of and…
A: public class ArrayInput { public static void main(String[] args) { int n =12 ; int[]…
Q: Question: Write a Template Class that stores three values of any type in an array as shown in the…
A: First, we will define the template. Then the member function. Then we will call the function of the…
Q: I am having some problems generating a random sphere coordinates of n points using Python. The…
A: Lets see the solution in the next steps
Q: Suppose you roll a set of n dice. Then the smallest sum is n and the largest sum is 6n. For example,…
A: Since you are not mentioning the programming language, here we are using C++ to complete the…
Q: Complete a class so that main works with constructor, destructor, copy constructor, operator= and…
A:
Q: Given the following class declaration (with prototypes): class NumberArray { private: double…
A: You can allocate memory for a variable of a specified form within the heap at runtime using a C++…
Q: Complete a class so that main works with constructor, destructor, copy constructor, operator= and…
A:
Q: (The Course class) Revise the Course class implementation in Listing 11.16, Course.cpp, as follows:…
A: The Complete answer in C++ Programming language is given below:
Q: Create a class called Employee with three attributes: Name, Salary and Id. Make constructors,…
A: Answer is given below-
Q: Define a “Invalidanalyze” function that accepts an array of “Course” objects. It will return the…
A: Answer: You didn't mention programming language So I did this program using java. Java Source Code:…
Q: Bookstore class uses a dynamic array to hold names book titles. class BookStore { public: BookStore…
A: A copy constructor initializes an object using another object of the same class. Situations when a…
Q: 15. Write a program that manages a list of up to 10 players and their high scores in the computer's…
A: Algorithm: 1. Take user input 1 for adding student, 2 for printing student, 3 for searching student,…
Q: Java : Overview You must write a class with which we can generate user identities for employees in…
A: public class Test { public static void main(String[] args) { String[] names = { "Bo Ek", "Erik…
Q: 3. Removе an el nt fror an Consider an array named source. Write a method/function named remove(…
A: #remove element at index idx from source and add 0 def remove(source,size,idx): source.pop(idx)…
Q: Java Overview In this task you must write a class with which we can roll five dice and then check…
A: Programming with arrays. Before considering more examples, we consider a number of important…
Q: import array as arr class expert: @staticmethod def add(a,b): return a+b; Write this code in pascal…
A: I'm writing your code in C sharp. Your C# program is given below with an output.
Q: Create a class ArrayList with the following functionalities as follow: ArrayList(); void PushBack(T…
A: 1. create a class array list and create a default constructor.2.Current size and maximum size set…
Q: Write a class called TwoDArray that has the following behaviors for an array of ints.…
A: Answer the above question are as follows:
Q: Class Gradebook2D The class Gradebook2D will produce the same output of the class Gradebook1D, but…
A: Program: //import the header file import java.util.Scanner; import java.text.DecimalFormat;…
Q: Question 4: Write Program in Java with following features a. The program asks user to provide an…
A: I have written the program code in step 2. I have also mentioned comments in the entire program .…
Q: Complete a program in a class ToyCounter that computes the cost of toys sold in a shop. Five kinds…
A: Program for create toyCounter and compute the total cost
Q: rite a class that implements a 'Set' of integers. set is a collection of items in which no item…
A: #include <iostream> #include <string> #include <conio.h> using namespace std;…
Q: Create a class TicTacToe that will enable you to write a complete program to play the game of…
A: Q: Code a tic tac toe game in c++
Q: develop a class productsales with static array 'sales' of size 12 where 0th index stores january.1st…
A: Code: import java.util.*;public class ProductSales{ //declaring static array of size 12 static…
Q: Extend the Array class adding the following two new methods: A) the method called min that…
A: ANSWER: (A) Smallest Number in Array: Output:
Q: You have probably come into contact with the dice game Yatzy1 before. In that game, it is a matter…
A: The below code is the solution for above problem statement....
Q: Exercise 2 - Numbers Create a new class called Numbers that contains a method called nextLargest.…
A: Given:
Q: Write a program that allows two players to play tic-tac-toe game. Your program must contain the…
A: #include <iostream>using namespace std;class TicTacToe{public:TicTacToe(); void…
Q: 2. A method named addElementTolndex that takes an array of double numbers, a double number to be…
A: import java.util.Arrays; public class arrayinsertatposition { public static void main(String[] args)…
Q: an int variable k, an int array currentMembers that has been declared and initialized, an int…
A: Given: an int variable k, an int array currentMembers that has been declared and initialized, an…
Q: class Solution { public int[] twoSum(int[] nums, int target) // .. } } Practice 2 Given an array of…
A: import java.util.HashMap; import java.util.Scanner; import java.util.Map; class TwoSum {…
Q: X440: Sorting - Create Bubble Sort Write a function in Java that takes in the int [] array,sorts it…
A: public int[] bubbleSort(int[] array) {int n = array.length;int temp = 0; }
Q: CLARRAY example shown here is a complete program that shows one way to create your own array class:…
A: The required C++ code is given below: // creates array class#include <iostream>using namespace…
Q: 6.19 LAB: Word frequencies - methods Define a method named getWordFrequency that takes an array of…
A: As language is not given doing it in Java Programming
Q: Java B. Create class and name it as ArrayOperation. Write the main function In the main function,…
A: Program plan: Create a class ArrayOperation Create a method UpperCase to convert and print the…
Q: Make a Java class for storing data of employee. Make a class Employee has data members eid(int),…
A: Solution import java.lang.System;//importing package // Class Employee and data membersclass…
Q: IN JS PROGRAMMING Given a word, Make sure the letters are the keys. Make sure the letters are…
A: Input - String Output - Map logic - for (let i = 0; i < str.length; i++) { if…
Q: 1. A method named findElement that takes a double number and an array of double numbers as…
A: Declare a function to find the index of an element. Find the length of the array. Create a list to…
Q: Write the code in java. Write code for PersonManagement class. This class contains the array of…
A: A class is the fundamental unit of object oriented modelling. A class contains data and operations…
Q: mergeAndRemove(int[], int[]) This is a public static function that takes a int[] and int[] for the…
A: Given function, mergeAndRemove(int[], int[]) This is a public static function that takes an int[]…
Q: Write a function that converts an object into an array, where each element represents a key-value…
A: In this problem, we need to design a code to convert the object / Map into the array. approach -…
Q: In C# Use a one-dimensional array to solve the following problem. Write a class called ScoreFinder.…
A: Find the code attached.
Q: umber String Name} Using the “Student” class write a Ja
A: Student class is defined as follows. Class Student {int Number String…
Q: You should decide the appropriate declaration and implementation. Write a test class create array of…
A: To Do: Write a Java program that solves each part.
Q: Write a checkbook balancing program. The program will read in the following information for all…
A: Algorithm of the program The algorithm of the program is: The main line of information shows the…
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images
- 9. Complete a program in a class ToyCounter that computes the cost of toys sold in a shop. Five kinds of toys-Zen, Leo, Star, Sam, and Barry-are stocked and cost, respectively, RM0.75, RM0.50, RM1.25, RM0.80 and RMO.75 per toy. Create an array of strings that holds the names of these toys. Create another array that holds the cost of each corresponding toy. Your program should read the name of a toy and the quantity desired by a customer. Locate the toy in the name array and use that index to find the cost from the cost array. Compute and print the total cost of the sale as output in Figure 8 below: E Output - test (run) #4 x :unz What kind of£ toy would you like? zen How many toy would you like? 10 zen: 10 at RMO.75 will cost RM7.5 Figure 8 Insert your answer here (Figure 9): import java.util.Scanner: public class ToyCounter public static void main (String [] args) double totalcost; int number; String() toyName - {"zen", double [] prices = (0.75, 0.50, 1.25, 0.80, 0.75): "leo", "star",…CODE IN JAVA PLEASE SEE THAT THERE SHOULD BE TWO .JAVA FILES ONE WITH CLASS AND OTHER WITH THE MAIN METHOD 3. 2D Array Write a class called TwoDArray that has the following behaviors for an array of ints. getTotal – Accepts a 2-D array as its argument and returns the total of all the values in the array getAverage – Accepts a 2-D array as its argument and returns the average of all the values in the array getRowTotal - Accepts a 2-D array as it first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The method should return the total of the values in the specified row. getColumnTotal - Accepts a 2-D array as it first argument and an integer as its second argument. The second argument should be the subscript of a column in the array. The method should return the total of the values in the specified column. getHighestInRow - Accepts a 2-D array as it first argument and an integer as its second argument. The second…Extend the Array class adding the following two newmethods:A) the method called min that returns the smallest numberin the array.E.g., applying min to the array [−3, 2, 0, −10, 9, 7], we get −10.B) the method called reverse that reverses the array.E.g., applying reverse to the array [−3, 2, 0, −10, 9, 7], we change itto [7, 9, −10, 0, 2, −3]. USE THE JAVA CODE BELOW TO ADD ON PLEASE public class Array {private int[] elems;private int nElems;public Array(int size) {if (size < 0) {throw new IllegalArgumentException();}elems = new int[size];}public void print() {System.out.print("[");for (int i = 0; i < nElems; ++i)if (i < nElems - 1) {System.out.print(elems[i] + ", ");} else {System.out.print(elems[i]);}System.out.println("]");}public void insert(int element) {// if the array is full, increases its sizeif (elems.length == 0) {int[] extendedElems = new int[1];elems = extendedElems;}if (elems.length == nElems) {int[] extendedElems = new int[nElems * 2];for (int i = 0; i <…
- 1. Write a class AnalyzeNumbers which asks the user to enter the number of inputs and stores them in an Array, then prints the Array that was inputted, calculates the sum of the numbers entered and prints the total numbers greater than the first inputted number: (15 points) Two Sample Runs Enter the number of items: 5 Enter the numbers: 3.4 5 6 7.1 9 You inputted: 3.4 5.0 6.0 7.1 9.0 Sum is: 30.5 Number of elements greater than the first element: 4 Enter the number of items: 3 Enter the numbers: 6.7 1.5 3.2 You inputted: 6.7 1.5 3.2 Sum is: 11.4 Number of elements greater than the first element: 0RU Rotten Tomatoes . Write a program RURottenTomatoes.java that creates a 2 dimensional integer array of movie ratings from the command line arguments and displays the index of the movie that has the highest sum of ratings. Ratings range from 1 to 5 (inclusive). The rows of the 2D array correspond to movie reviewers and the columns of the 2D array correspond to movies. The reviewer at index 2 gave movie at index 0 a rating of 4. Take a look at the following example for an explanation on the command line arguments sequence. java RURottenTomatoes 3 2 5 2 3 3 4 1 0 1 0 5 2 1 3 3 2 4 1 The first argument corresponds to the number of reviewers and the second argument corresponds to the number of movies (the dimensions of the 2D integer array). Following are the movie ratings in a row-major order.…-CLO3- Question No 1: (Array of primitive values) Initialize an array of double values of size 10, with user input. Then calculate and display the sum and average of these values. Question No 2: (Array of objects) Create a class Student having rollno and name as private instance variables. write a program that creates studentArray of five students; it then initializes all students rollno and name by using an input function that will initialize and return an array of five students. and display function that displays the values of all students the array which is passed to it.
- Class Gradebook2D The class Gradebook2D will produce the same output of the class Gradebook1D, but the implementation will be slightly different. You will need to use only two arrays: One array of type int to store all the ID's (just like the previous class). One two‐dimensional array of type double to store all the scores for all quizzes. Example: Assume there are 10 students in the class, then the id array will have 10 indices. 0 1 2 3 4 5 6 7 8 9 132 451 854 523 153 588 351 856 142 445 Each quiz array will store in the index that corresponds to the student the score for the quiz. 0 1 2 3 4 5 6 7 8 9 100.0 90.0 85.0 92.0 75.0 93.0 98.0 100.0 95.0 87.0 90.0 87.0 92.0 95.0 78.0 84.0 88.0 96.0 100.0 95.0 100.0 98.0 85.0 98.0 87.0 89.0 92.0 88.0 92.0 97.0 Student with ID 153, at index 4, has taken all three quizzes with scores 75.0 (quiz 1), 78.0 (quiz 2) and 87.0 (quiz 3). Note: The two dimensional array can be represented also with the rows being the students and the columns…JAVAWrite a program that searches person's name and display all matched name. For example, if a user inputs the letter "Davis", the program searches all name which includes "Davis" in an array. Then, display all matched names on the screen. You must declare a single dimensional array which has all people’s name. Use methods of string classWrite a CarParking class to model a multistory car parking building. This class should contain a 3- dimensional array of type Vehicle. The third dimension of the array simply represents the number of floors of the building while the first and second dimensions are the number of rows and columns in every floor. By default, there are 3 floors, 7 rows and 7 columns in a building. However, the user should be able to specify the maximum number of floors, rows and columns at the time of creating a CarParking object. In addition to the constructors, this class should provide the following methods: O public boolean isOccupied (int floor, int row, int col) this method returns true if the location specified by the floor, row and column is already occupied by a vehicle. o public void add (Vehicle v) this method will add the vehicle at the next empty slot. Slots are field row by row (from left to right) starting from the ground floor. public Vehicle remove (int floor, int row, int col, double…
- Pseudocode for Java code Write the algorithm in pseudocode for a method that accepts three parameters: an integer array, an integer representing the number of valid values in the array, and an integer representing a factor. The method will count the number of valid values in the array that are multiples of the factor and will return the count. There is a Java operator that might be very helpful in solving this problem. Testing Above problem: Assuming that the first two parameters are an array containing 4, 10, 15, 12, 8, 20, 100, 25, 32, 7, 28, and 48 and the number 12, come up with three good test cases for the factor and the return value. factor numMultiplesWrite a class with name Arrays . This class has an array which should be initialized by user.Write a method Sum that should sum even numbers in array and return sum. write a function with name numFind in this class with working logic as to find the mid number of an array. After finding this number calculate its factorial.Write function that should display sum and factorial.Don’t use divide operatorProblem: We need a program that takes 8 products and makes calculations and informs the user. Products have name, type and cost. Write the program that takes name,type and cost information from the user and saves the product objects to an array and calculates the total cost, the one with the most cost and the one with the least cost. For example: Banana Fruit 10 Apple Fruit Trousers Textile 50 T-Shirt Textile 30 Pencil Office 15 Office Раper Strawberry Computer 10 Fruit 20 Electronics 6000 Total Cost: 6140 TL Most Expensive: Computer Least Expensive: Apple