Question 12 C. Copy the following code (last line below) into the main method of a new class. Finish the class by printing out the array as a grid (shown below) where every number that is odd is replaced by two spaces. Eg. if you had an array with three rows and three columns, it would print out 10 20 40 50 зе 10 noticed that three spots are blanks - these would have been numbers which are odd int[][] array = { {10, 20, 1}, {40, 1, 50}, {1, 30, 10} };
Q: 2. In your main class: a. Define the method addElement which takes an array of integers and an…
A: Note : - I made this code runnable So I Included the driver Code also to run the program . So this…
Q: Implement all the classes. The formula for calculating salary for each class is shown below: For…
A: Below is the code in java and sample output:
Q: This is the question I am stuck on - In the exercises in Chapter 6, you created a class named…
A: The main objective of the program is to create three methods, called sortBySaleAmount,…
Q: (B) Write a Java program that crates an array of 100 random lowercase letters, and then converts a…
A: The name of the Java class is Letters. Using the block/paragraph comment write the student name and…
Q: write a Java code! Overview In this task you must write a class with which we can roll five dice…
A: import java.util.Random; public class Yatzy { int[] dices; public Yatzy() { this.dices = new…
Q: Write a program in a class FlowerCounter that computes the cost of flowers sold at a flower stand.…
A: import java.util.Scanner; public class FlowerCounter { public static void main(String[] args) {…
Q: Write a RainFall class that stores the total rainfall for each of 12 months into an array of double…
A: import java.text.*; import javax.swing.*; import java.util.Scanner; class RainFall { static…
Q: lass contains three independent static methods and contains no fields (none should be added). The…
A: It is defined as a user defined blueprint or prototype from which objects are created. It…
Q: I got part of this code right but the other part I dont this is the question - In the exercises in…
A: In the question, it was stated: "continuously prompt until the user enters an invoice number between…
Q: In this task you must write a class with which we can roll five dice and then check if we have got…
A: import java.util.Random; public class Yatzy { int[] dices; public Yatzy() { this.dices = new…
Q: With reference to the classes defined question #1, write a method called identifyPersons() that…
A: In this Java application, the following classes are created: Class Person Attributes: name,…
Q: (B) Write a Java program that crates an array of 150 random uppercase letters, and then converts a…
A: In Java, Math.random() is used to return a pseudorandom double type number greater than or equal to…
Q: Please can some1 solve this C++ Question ! C++ PLS !! Write a class called CoffeeShop, which…
A: Program Explanation- Constructor to initialize all variables. Getters for all instance variables.…
Q: 1. Create a class with the main() method. 2. Take a string array input from the user in main()…
A: Required:
Q: 3. Write a method oddDice() that takes an array of Die objects as a parameter. The method rolls each…
A: Step 1 : Start Step 2 : In the Die class declare an integer member Die_Num. Step 3 : Define a method…
Q: Exercise #2 Write a method that takes one dimensional array of type Book and returns the average…
A: Actually ,program is an executable software that runs on a computer.
Q: Write a program that simulates inventory bins in a warehouse. Each bin holds a number of the same…
A: #include <iostream>#include <iomanip> using namespace std; void DisplayBin (int [],…
Q: This is the code that I am unsure where to fully start -
A: Approach For loop is used to iterate over Purchase array length. In the loop, the user is asked to…
Q: 1)Write a method that takes an array of ints and returns the sum of all numbers that are even. For…
A: NOTE : Answering only the first question as per the policy. Since programming language is not…
Q: Create a class named Problem1, the program (Java) would do the following: -The program prompts the…
A: The answer to the given question is in subsequent steps.
Q: Assume class ArrayStack has been deńned using the implementation in your textbook and that myStack…
A: Answer:-
Q: Write a program that simulates inventory bins in a warehouse. Each bin holds a number of the same…
A: #include<iostream> using namespace std; class InventoryBin{string desc;int noOfPart;public:…
Q: fill in the table to trace the values as they are passed from main and changed in the method.
A: Giving Answer for only (a) part Given Program int [] array = {1,2,3,4,5}; int x = 12; int y =…
Q: Problem #1: Write a method that takes an array of integers and shifts it to the right by one…
A: Indentation is used to make the code readable to other users because it makes the code easier to…
Q: Write (define) a public static method named getInRange, that takes three arguments. The first…
A: public class Main{ public static void main(String[] args) { int[] myArray = {1, 22, 333, 400,…
Q: define an object of this class?
A: Given a class definition, which one correctly define an object of this class? b. Holiday year;
Q: Write a method that accepts an array of integers as a parameter and returns a reference to an array…
A: First count the number of even numbers Then create the array with this count size Then, assign the…
Q: Write two overloaded methods that return the average of anarray with the following headers:public…
A: Program code: //import the required packages import java.util.Scanner; //define a class public…
Q: I need to have a main method in a Tester class that will: Fill an array of type Vehicle[] of size…
A: class Vehicle{ private double efficiency; Vehicle(double efficiency){ this.efficiency=efficiency;…
Q: The following block of code is intending to display the values that store in array. public static…
A: Hi, since there are multiple questions in this post, as per our policy, I'll answer the first…
Q: // Among indexes first...last, return index of the target. // If target is not present then return…
A: Task : Complete the given method to a working java code. I have completed the given method using a…
Q: C. Given the code snippet below, the method "contains" is meant to retun true or false if a "value"…
A: Part C In the code snippet above has errors. They have defined contains method as void. Void method…
Q: In this task you must write a class with which we can roll five dice and then check if we have got…
A: public class TestYatzy { public static void main(String[] args) { int games = 10000000, yatzyCount…
Q: Intellij - Java Write a program which does the following: Create a class with the main() method.…
A: Algorithm: Start Read array size Read array of strings Using Arrays.toString() print array…
Q: Write a Java method that reverses a given array. the method that reverses the array passed in the…
A: reverse array method:- public static int[] reverse(int arr[],int n) { int i=0,j;…
Q: Based on the information in the screenshots, please answer the following question below. The…
A: Answer is given below .
Q: a)Implement all the classes. The formula for calculating salary for each class is shown below: For…
A: Inheritance is the feature of the object oriented programming language. Java supports inheritance.…
Q: 4.write a method that receives an array and shuffles the array randomly
A: Here we are talking about an array. Array is type list in which we enter the elements of…
Q: art Description Number of Parts in the Bin Valve…
A: #include <iostream>002#include <iomanip> using namespace std; void showBin (int [],…
Q: Write a code in JAVA for storing information of Employee using array. Employee attributes for…
A: Program approach:- Then creating an array class to store the employee's objects. Using add method…
Q: in a loop that continues until a user inputs a sentinel value of Z, ask the user whether the…
A: Program Understanding Here, we have used a while loop that continues until a user enters 'Z' to…
Q: Write a program that simulates inventory bins in a warehouse. Each bin holds a number of the same…
A: A class is the basic building block of object oriented programming. A class can also contain another…
Q: b. In the main method, The program reads from the user the number of branches in the company. The…
A: Step 1 : Start Step 2 : Create a method getBranchSalariesSum to compute the Maximum salary given by…
Q: Description: Write a method that return the average of an array with the following header: public…
A: Step-1: StartStep-2: Declare an array of size 5 and take input array element from userStep-3: Call…
Q: Please help write this in C++, I am kinda lost. bagDifference: The difference of two bags is a new…
A: Python 2.7 code : #function to find difference between two bags i.e (bag1 - bag2)def…
Q: Define a static void method, which receives as an parameter an array of salaries (of type double)…
A: Step 1:- Program Approach:- 1.Use the user-defined function whose name is converted (float [] array)…
Q: Write a code in JAVA for storing information of Employee using array. Employee attributes for…
A: Note : No output is given for this solution as it is mentioned not to write the main method .I have…
write a code in java that has a row of 3 and a column of 3 and prints out the even numbers but if there is an odd number it instead prints it the space blank
Step by step
Solved in 3 steps with 1 images
- ) Modify the BookStore and BookSearchEngine classes explained in the class to include the following additional methods and test them:a) A method returning the book with the lowest price in the library.b) A method searching the library for Books of a given author and returning an ArrayList of such Books. c) A method returning an ArrayList of Books whose price is less than a given number.Question: 1. Write a method that has an int parameters. Creates an array of integers of that size. Reads in values for the array from the user. Returns the newly created array. 2 Write a method that given an array of integers.returns the index of the smallest integer.Java Problem: Implementing a method to print a cell's neighbors on a 2D array. The method's header is provided. The main method (do not alter it)w ill read N numbers to create the 2D array and it will call the method for you. Do not go out of the bounds of the 2D array. I have attached what it should look like with the following input: 4 4 1 2 3 4 7 8 9 10 13 14 15 16 19 20 21 22 2 2 Code I have so far: import java.util.Arrays;import java.util.Scanner;public class Problem3 {public static void printNeighbours(int[][] data, int row, int col){}public static void main(String[] args) {Scanner kb = new Scanner(System.in);int[][] data = new int[kb.nextInt()][kb.nextInt()];for (int i = 0; i < data.length; i++) {for (int j = 0; j < data[0].length; j++) {data[i][j] = kb.nextInt();}}System.out.println("The 2D Array:");for (int[] cols : data) {System.out.println(Arrays.toString(cols));}int row = kb.nextInt();int col = kb.nextInt();System.out.printf("The centre point is: %d %d…
- . Create a testEmployees class. Do the following: Declare an array called arrEmp of 10 Employee type objects in the main method. Write a static method called fillArray() that receives the arrEmp array. Use a while loop to enter the information (type of contract) of a number of new employees. Quit input by entering the character X instead of the type of contract. For each employee create an object and save the object in the array. Return the array to the main method. Call the static fillArray() method from the main method. Write a static method called displayArray() to receive the array and display a numbered list of the information of the employees using a for-loop and the toString() method. Call the static displayArray() method from the main method. Write a static method called updateEmpCommission() to receive the array and update the commission of some of the employees as follows: Use a loop to update a number of employees' commission. Use a sentinel value -1 to…The assignment will be similar to an assignment used frequently in CS116 classes. You will be given an integer array of positive numbers. Your program should process the array and do the following for each entry: Determine if the number is odd or even. Add to a counter for each type, i.e. an even counter and an odd counter. Add the number to a sum for each type, i.e. a total of the odd numbers and a total of the even numbers. A value of -999 indicates the end of the array. Your program should end at that point. The input will be the following variable in your program: L3Array DCD 22,9,333,47,72,128,111,44,-999 The actual number of array entries and their values will be different when your program is graded. The last number will still be -999. The output of your program will be the counts and totals placed in the following variables: L3OddCt DCD 0 ; count of odd numbers L3OddTot DCD 0 ; total of odd numbers L3EvCt DCD 0 ; count of even numbers L3EvTot DCD 0 ; total of even…The assignment will be similar to an assignment used frequently in CS116 classes. You will be given an integer array of positive numbers. Your program should process the array and do the following for each entry: Determine if the number is odd or even. Add to a counter for each type, i.e. an even counter and an odd counter. Add the number to a sum for each type, i.e. a total of the odd numbers and a total of the even numbers. A value of -999 indicates the end of the array. Your program should end at that point. The input will be the following variable in your program: L3Array DCD 22,9,333,47,72,128,111,44,-999 The actual number of array entries and their values will be different when your program is graded. The last number will still be -999. The output of your program will be the counts and totals placed in the following variables: L3OddCt DCD 0 ; count of odd numbers L3OddTot DCD 0 ; total of odd numbers L3EvCt DCD 0 ; count of even numbers L3EvTot DCD 0 ; total of even…
- This is the question I am stuck on - In the exercises in Chapter 6, you created a class named Purchase. Each Purchase contains an invoice number, amount of sale, amount of sales tax, and several methods. Now, write a program that declares an array of five Purchase objects and prompt a user for their values. As each Purchase object is created, continuously prompt until the user enters an invoice number between 1000 and 8000 inclusive and a non-negative sale amount. Prompt the user for values for each object and then display all the values. This is the code that I am unsure where to fully start - public class Purchase { private int invoiceNumber; private double saleAmount; private double tax; private static final double RATE = 0.05; public void setInvoiceNumber(int num) { invoiceNumber = num; } public void setSaleAmount(double amt) { saleAmount = amt; tax = saleAmount * RATE; } public double getSaleAmount() { return…You will use the array bag code that we reviewed in the text book. This code is provided with this assignment. In this code I have added one new method to the class for you to use as a guide. write 3 new methods in the ArrayBag class: bubbleSort - a method to sort the array in ascending order using the bubble sort binarySearchIterative – a repetitive version of the binary search binarySearchRecursive - a recursive version of the binary search (You should use a helper method that calls the recursive method so the client code does not have to provide the extra parameters. Client calls to both of the search methods should be identical other than the method name.) Load your bag with some initial values, but do not fill it completely. Your client code should give the user the option to: display the contents of the bag using the class method “toVector” add values to the bag remove values from the bag sort the bag search for a value using their choice of either the iterative search or the…1. Declare an array to save 4 Dog objects. The Dog class is provided below. Look into the Dog class and find what attributes are needed for a dog object. Then initialize five dogs with the following information: Lily, 5 years old Jacob, 2 years old Sugar, 8 years old Bush, 3 years old 2. Print out every dog using a for loop (use either regular for loop or for-each loop, your choice). But you may find when you print out, the name and age are not displayed. Why? 3. Fix this problem by implementing the toString method in the Dog class. Dog Class: public class Dog { private String name; private int age; public Dog(String name, int age) { this.name = name; this.age = age; } public void setName(String name) { this.name = name; } }
- Blackjack is a card game where the goal is to reach a score of 21. Create a java version of this game with the following requirements. Extend the JPanel class and create an array of 52 cards. Add four sets of numbers from 1 to 10. Use J for Jack, Q for queen, K for king, and A for ace. Jack through king will have a value of 10, and the ace will have a value of 11. Deal two cards to the user and two cards to the computer. Do not show the value of the computer's first two cards to the user. Add buttons Hit, Stay, and Reset. If the user selects the "Hit" button, randomly select one of the cards from the array, and give it to the user. (After selecting a card, do not reuse this index during the rest of the game.) If the dealer has less than 21, "hit" the dealer, too. When the user selects the "Stay" button, add up the card values. The winner is the person who is closest to 21 without going over. Name the class Blackjack.java.Problem: Write a method that will determine whether a given value can be made given an array of coin values. For example, each value in the array represents a coin with that value. An array with [1, 2, 3] represents 3 coins with the values, 1, 2, and 3. Determine whether or not these values can be used to make a desired value. The coins in the array are infinite and can only be used as many times as needed. Return true if the value can be made and false otherwise. Dynamic Programming would be handy for this problem. Data: An array containing 0 or more coin values and an amount. Output: Return true or false. Sample Data ( 1, 2, 3, 12, 5 ), 3 ( 4, 15, 16, 17, 1 ), 21 ( 1 ), 5 ( 3 ), 7 Sample Output true true true falseExercise 2: Write array methods that carry out the following tasks for an array of integers by creating and completing the "ArrayMethods" class below. Add documentation comments for each method. Provide a test program called Labs_yourID.java" that tests methods of ArrayMethods class. In your test program, use random class to generate array values. public class ArrayMethods prívate int[ ] values: //declare instant variables public ArrayMethods (int[] initialValues) (values = initialValues:) //constructor public void shiftRight() () public boolean ad jacentDuplicate() () ... • Method shiftRight: that shifts all elements by one to the right and move the last element into the first position. For example, 1 49 16 25 would be transformed into 25 1 4 19 16. • Method ad jacentDuplicate: returns true if the array has two adjacent duplicate elements.