Write a program that finds the average of all positive, non-zero values found in a given array of double prints that to the console Any negative or zero values do not contribute to the average.
Q: The element that has been in a queue the longest is at the "rear" of the queue. True False
A: Actually queue follow the first in first out . But it doesn't depends upon the value of elements.
Q: Computer Science Binary Search Tree Implement Binary search Tree (BST) and perform the following ope...
A: A binary search tree is a type of tree that contains the values in a specific order. Given keys are1...
Q: How can we keep our anonymity on the internet
A: Please find the answer below
Q: A multicore computer is a computer that has a lot of different parts.
A: > True A multicore computer is a computer that has lot of different parts
Q: j. Declare a string variable containing the word "TEST" repeated 500 times. k. Declare an array of 2...
A:
Q: Computer Science Write the following two programs: Extend the multi-threading Java program to a...
A: class RunnableDemo implements Runnable { private Thread t; private String threadName; Runnable...
Q: 1. Using the Pumping Theorem, show that the language {a²´ | n > 0} is not regular.
A: Given, The answer is given below
Q: In the face of substitutability, invocation of overridden methods makes use of _ binding, in which t...
A: Dynamic Binding: When type of the object is determined at run-time, it is known as Dynamic Binding....
Q: What are the challenges with logically controlled loop statements in terms of design?
A: Introduction: All loops in C are logically controlled (whatever that means): the value of the contro...
Q: B. If Alice uses the same k to encrypt two messages M1 and M2 as (12, 65) and (12, 64), what is the ...
A: The answer is
Q: Suppose that L is a context-free language and that R is a regular language. Is L - R necessarily con...
A: Concepts: Operation that does not close context-free language: Set difference, intersection, and c...
Q: C++ Programming Instructions Write a program that prompts the user for a sequence of characters (...
A: Use strlength () function to count the number of characters . Below is the code:
Q: Consider the following Python program (note that Python uses indentation to specify scope): 010 x = ...
A: Introduction: Here we are required to find the variables accessible in the body of sub2()
Q: What is the mentor system and buddy system?
A: Intro Mentoring is the Employee training system under which a senior or more experienced individua...
Q: for i in range(- print(i) --):
A: Please find the code below
Q: Let S1 and S2 be two stacks. 1. It is possible to keep two stacks in a single array, if one grows fr...
A: Create a data structure twoStacks that represents two stacks. Implementation of twoStacks should use...
Q: Write, compile, and test the Comments class that uses the command window to display the following st...
A: Here is the detailed explanation of the code.
Q: When is it most appropriate to do a binary search?
A: 1) Binary Search is a searching algorithm used in a sorted array by repeatedly dividing the search i...
Q: (Computer Graphics)Using the Cohen-Sutherland line clipping algorithm, clip the line PQ with coordin...
A: Cohen Sutherland technique for line scraping: This Messner procedure is a column-cutting graphic des...
Q: Discuss the extent to which the choice of lifecycle models impacts, influences, and determines proje...
A: The answer is given below:-
Q: How do you determine the smallest value in a tuple? Python
A: the answer is given below:-
Q: Nowadays, thanks to technological advancements, the majority of appliances are wireless-capable. Is ...
A: I attached your answer below.
Q: In 1-2 double spaced pages, please respond to the following: What is job analysis? In what areas (or...
A: The word count in 1-2 double spaced page is around 250 words. ..................
Q: 3.7 Assume 185 and 122 are signed 8-bit decimal integers stored in sign-magnitude format. Calculate...
A: calculate 185 + 122
Q: Exercise 1-8 Write and submit a python program that draws a matrix of dots in the order indicated by...
A: PROGRAM EXPLANATION: Import the turtle. Create a turtle object. Use the hide turtle function to hid...
Q: A Java-supplied default (a.k.a. a no-argument, or no-args) constructor (i.e., a constructor that tak...
A: 1) Java compiler automatically creates a default constructor i.e. a constructor with no arguments, i...
Q: 2. Consider the system to be 64 bit, answer the following question in accordance to C language, i) ...
A: To find the size of int, char, int *, and char *, consider the system to be 64-bit and in accordance...
Q: Calculate the profit (profit) as the retail price minus the wholesale price Calculate the sale price...
A: As given, we need to write a C++ program as per the given requirements. I have provided the complete...
Q: Write C assignment statements for the following: a. Assign a value of 0 to a variable called betwee...
A: a: PROGRAM EXPLANATION: Include the header file. Define the main function. Create a variable n with...
Q: Coding problems: HW5_2 A thin square metal plate has uniform temperature of E1 47, = E, + E2 + T2 + ...
A: Here is the solution with an output:-
Q: (b). What method is included in the client code?
A: Following methods are included in client code:- getSecurityManager()getOutputStream()readLine()
Q: allocation
A: Computer programs and services assign physical or virtual memory space by a process called memory al...
Q: (b) p→~9
A: Lets see the solution.
Q: b) When does the best case and worst-case complexity occurs in Quick sort? Explain it with the help ...
A: Quick sort is the fastest way of sorting elements in the list. Here in this sorting algorithm, one e...
Q: What exactly is the Single Audit Act, and how does it function? What effect has this statute had on ...
A: Introduction: Single Audit Act: All recipients of grants and funding are expected to compile their f...
Q: Question 2: A student will not be allowed to sit in exam if his/her attendance is less than 75%. Tak...
A: According to the information given:- We have to follow the instruction and code to get desired outpu...
Q: In computer memory, how do local declarations get put in place? Yes, but there aren't any good reaso...
A: Introduction Memory Allocation: The technique by which the software creates "space" for information...
Q: 1. Collect and manage real time applications data, information and knowledge of your department/city...
A: 1. Collect and manage real time applications data, information and knowledge of your department/city...
Q: Describe how functional dependencies may be used to denote the following: • The entity sets student ...
A: Functional dependency is a relationship that exists between two attributes. It typically exists betw...
Q: "Rabenstein code was used to send a message with 4 information bits, you receive 100110001, if you c
A: The answer is
Q: What are the uses of DEFINE and DESCRIBE? Please expand and elaborate. DEFINE uses: DESCRIBE ...
A: Answer: DEFINE uses: Define means to precisely describe or state the nature, scope, or meaning of so...
Q: Which data structure to use? Suppose you need to store a list of elements, if the number of elements...
A: Which data structure to use? Suppose you need to store a list of elements, if the number of elements...
Q: If the input is 5. 0 2.5 1.5 the output is 55.90170 579.32402 5.00000 6.64787
A: here is Pseudo-Code of the :- (i) start (ii) input three floating number (iii) calc...
Q: write a c++ program that will ask the user to input 10 numbers. Cout the number of even number from ...
A: PROGRAM EXPLANATION: Include the header file. Define the main function. Create an integer variable ...
Q: Who made the first flash drive?
A: These gadgets store data without external power and turn it on when a commuter connects through a ...
Q: What is the function of a router in networking?
A: Intro A router is a network switching system that can route data packets to other networks or device...
Q: GoldStar Bank is helping companies to do money transaction for their customers who holds their credi...
A: The solution is given below for the above given question:
Q: The_ keyword is used in a subclass constructor to explicitly control the superclass constructor that...
A: The subclass may have its own private data members, so the subclass may have its own creators. The c...
Q: s to other parts.
A: given - A mobo is a part of a computer that connects to other parts.
Q: What component of hardware enables a device's physical network connection?
A: Network Interface Cards. A network interface card (NIC) establishes a physical connection between a ...
java
Step by step
Solved in 2 steps with 1 images
- Problem 1: Complete the sumOfDiagonals method in SumOfDiagonals.java to do the following: The method takes a 2D String array x as a parameter and returns no value. The method should calculate and print the sum of the elements on the major diagonal of the array x. In order to have a major diagonal, the array passed into the method should be a square (n-by-n), if it's not a square your program should handle that situation by throwing an exception. (Do Not worry about ragged arrays) If the array is a square, but there is a non-integer value on the major diagonal, your program should handle that situation by throwing an exception. When handling the exceptions, be as specific as you can be, (i.e. Do Not just use the Exception class to handle all exceptions in one catch block). Make the proper calls to the sumOfDiagonals method from the main method to test your sumOfDiagonals method on all the String arrays provided in the main method.ANSWER IN JAVA: Write an application that inputs five numbers, each between 10 and 100, inclusive. As each number is read, display it only if it’s not a duplicate of a number already read. Provide for the “worst case,” in which all five numbers are different. Use the smallest possible array to solve this problem. Display the complete set of unique values input after the user enters each new value. NOTE: looking for the output to appear on three lines as shown in the results STANDARD OUTPUT: Enter·an·integer·between·10·and·100:This·is·the·first·time·100·has·been·entered↵ Enter·an·integer·between·10·and·100:Enter·an·integer·between·10·and·100:This·is·the·first·time·10·has·been·entered↵ Enter·an·integer·between·10·and·100:This·is·the·first·time·20·has·been·entered↵ Enter·an·integer·between·10·and·100:The·complete·set·of·unique·values·entered·is:↵ Unique·Value·1:·is·100↵ Unique·Value·2:·is·10↵ Unique·Value·3:·is·20↵Write code that loops through the array myVals. Each iteration: If myVals[i] is less than smallestNum, assign smallestNum with myVals[i]. Remember to assign smallestNum with some value before the loop.
- Write a program that lets the user enter the total rainfall for each of 12 months (starting with January) into an array of doubles. The program should calculate and display (in this order): the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Months should be expressed as English names for months in the Gregorian calendar, i.e.: January, February, March, April, May, June, July, August, September, October, November, December. Do not accept negative numbers for monthly rainfall figures. When a negative value is entered, the program outputs "invalid data (negative rainfall) -- retry" and attempts to reread the value. NOTE: Decimal values should be displayed using default precision, i.e. do not specify precision.Write the following methodthat tests whether the array has four consecutive numbers with the same value:public static boolean isConsecutiveFour(int[] values)Write a test program that prompts the user to enter a series of integers and displaysit if the series contains four consecutive numbers with the same value. Yourprogram should first prompt the user to enter the input size—i.e., the number ofvalues in the series. Here are sample runs: Enter the number of values: 8↵EnterEnter the values: 3 4 5 5 5 5 4 5↵EnterThe list has consecutive foursEnter the number of values: 9↵EnterEnter the values: 3 4 5 5 6 5 5 4 5↵EnterThe list has no consecutive foursA chess has ABCD andEstudents. They take a test for 100 points. Write a program which takes input of test scores fiom the gouder and gives the letter grade for the students and the averye score of the class. Use Array \& loop.
- 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 numMultiplesComplete the following program ArrayMax.java. The function max() should return a new array containing the max value of each corresponding value in two arrays. Below is the code, with the section that needs to be completed. The output should look exactly like what is given below, alsoA bit new to methods and need a little bit of help. Swap Method Your task is to write a public static method named swap that takes a single parameter which is an array of doubles. This method should swap the first and last element in the array and then return the adjusted double array. You can assume that all arrays passed into the method are a length of 2 or more. For example, the test data provided when passed into the swap method should go from: {8.34, 7.221, 10.643, 93.2} to
- Problem: 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: AppleJavanetbeans Use a one-dimensional array to solve the following problem: Write an application that inputs five numbers each of which is between 10 and 100, inclusive. As each number is read, display it only if it is not a duplicate of a number already read. Provide the “worst case”, in which all five numbers are different. Use the smallest possible array to solve this problem. Display the complete set of unique values input after the user inputs each new value Initialize the integer array numbers to hold five elements. This is the maximum number of values the program must store if all values are input. 2. Validate the input and display an error message if the user inputs invalid data. 3. If the number entered is not unique, display a message to the user; otherwise, store the number in the array and display the list of unique numbers entered so far.Problem Statement Particulate matters are the biggest contributors to Delhi pollution. The main reason behind the increase in the concentration of PMs include vehicle emission by applying Odd Even concept for all types of vehicles. The vehicles with the odd last digit in the registration number will be allowed on roads on odd dates and those with even last digit will on even dates. Given an integer array all, contains the last digit of the registration number of N vehicles traveling on date D(a positive integer). The task is to calculate the total fine collected by the traffic police department from the vehicles violating the rules. Note: For violating the rule, vehicles would be fined as X Rs. Example 1: Input : 4-> Value of N (5,2,3,7) -> a[], Elements a[0] to a[N-1], during input each element is separated by a new line 12 -> Value of D, i.e. date 200 > Value of x i.e. fine