Concept explainers
(Displaying a Square of Asterisks) Write a method squareOfAsterisks that displays a solid square (the same number of rows and columns) of asterisks whose side is specified in integer parameter side. For example, if side is 4, the method should display
* * * *
* * * *
* * * *
* * * *
Incorporate this method into an application that reads an integer value for side from the user and outputs the asterisks with the squareOfAsterisks method.
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Java How To Program (Early Objects)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out with C++ from Control Structures to Objects (8th Edition)
C How to Program (8th Edition)
Starting Out With Visual Basic (7th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Artificial Intelligence: A Modern Approach
- java programming: pleas see attachment as well***** In this task, you are asked to write a program called Swap.java, including at least 3 following methods: - Main() swapDigitPairs ( parameter) - swapLetterPairs (parameter) In the main method, - Use your Panther Number as the input argument, call swapDigitPairs ( parameter) - Ask user to input a number and call a method swapDigitPairs to swap the number as shown in the example of the following figure. - Ask the user to input a string of letters/numbers and call a method swapLetterPairs to swap the letters as shown in the following example. - swapDigitPairs ( parameter) - swapLetterPairs (parameter) In the main method, - Use your Panther Number as the input argument, call swapDigitPairs ( parameter) - Ask user to input a number and call a method swapDigitPairs to swap the number as shown in the example of the following figure. - Ask the user to input a string of letters/numbers and call a method swapLetterPairs to swap the letters…arrow_forward" *", or "/"). The method should throw ar Write a method that computes the value of an arithmetic expression. The operator string should be one of ("+",' IllegalArgumentException otherwise. Also throw an IllegalArgumentException if the operator is "/" and the second argument is zero. II II Arithmetic.java 1 public class Arithmetic 2 { /** Computes the value of an arithmetic expression @param valuel the first operand @param operator a string that should contain an operator + @param value2 the second operand @return the result of the operation */ public static int compute(int valuel, String operator, int value2) { if (operator.equals("+")) { return . . .; } else if (operator.equals ("-")) { return else if (operator.equals ("*")) { return else if (operator.equals("/")) { 4 * or / 7 8. 9 10 11 12 } } 13 14 15 16 17 } else 18 19 20 21 } } 22 23 24arrow_forwardJava code Screenshot and output is mustarrow_forward
- *In Java Problem Description and Given Info Write a public static method named countGreaterThanAverage that will take an int array as it's only argument. This method will return an int value. When called, and passed an array of int values, this method will compute and return the number of values in the argument array that are greater than the average of all the values in the argument array. Here are some examples: Example 1 Given: int[] myArray = {1, 2, 3, 4, 5}; countGreaterThanAverage(myArray) should return 2 Example 2 Given: int[] myArray = {13, 7, 6, 5, 99, 10, 4, 8}; countGreaterThanAverage(myArray) should return 1 Example 3 Given: int[] myArray = {1, 1, 1}; countGreaterThanAverage(myArray) should return 0 Helpful Info: You may want to write a main method to call and test your required method There should be no System.out.print or System.out.println statements in your countGreaterThanAverage method There should be no calls to any Scanner methods (like next, nextLine, or…arrow_forwardUse Java programming language Write a program that asks the user to enter 5 test grades (use an array to store them). Output the grades entered, the lowest and highest grade, the average grade, how many grades are above the average and how many are below and the letter grade for the average grade. Create a method that returns the lowest grade. Create a method that returns the highest grade. Create a method that returns the average grade. Create a method that returns how many grades were above the average. Create a method that returns how many grades were below the average. Create a method that returns the letter grade of the average (90-100 – A, 80-89 – B, 70-79 – C, < 70 – F)arrow_forwardExercise GradesStatistics (Method): Write a program called GradesStatistics, which reads in n grades (of int between 0 and 100, inclusive) and displays the average, minimum, maximum, median and standard deviation. Display the floating-point values upto 2 decimal places. Your output shall look like:Enter the number of students: 4Enter the grade for student 1: 50Enter the grade for student 2: 51Enter the grade for student 3: 56Enter the grade for student 4: 53{50,51,56,53}The average is: 52.50The median is: 52.00The minimum is: 50The maximum is: 56The standard deviation is: 2.29The formula for calculating standard deviation is:Hints:public class GradesStatistics {public static int[] grades; // Declare an int[], to be allocated later.// This array is accessible by all the methods.public static void main(String[] args) {readGrades(); // Read and save the inputs in int[] gradesprintArray(grades);System.out.println("The average is " + average(grades));System.out.println("The median is " +…arrow_forward
- use java as programming languagearrow_forwardProblem specification: There is a grid of NXN squares. We can easily determines how many different rectangles (squares are excluded) there are in the grid. For example, in a 3X3 grid, you can find 22 different rectangles, marked as the green rectangles. You can see that we did not count the red ones as they are squares. In this assignment, you will write a Java program that takes the value of N as input and determines the total area of all the rectangles in the grid. Assume that the smallest squares in the grid have length 1. So a 3X2 rectangle will have an area of 6. For example, the total area of all the rectangles in the 3X3 grid is 66.…arrow_forwardJava: Write a complete method to create an array of random integers. Method Specification The method takes in three integer parameters: the array size, the lower bound, and the upper bound. The method also takes in a boolean parameter. The method creates and returns an integer array of the specified size that contains random numbers between the lower and upper bound., using these rules: The lower bound is always inclusive. If the boolean parameter is true, the upper bound is also inclusive. If the boolean parameter is false, the upper bound is not inclusive (meaning it is exclusive). If any of the parameters are invalid, null is returned. Driver/Tester Program I have provided you with a driver/tester program that you can use to test your code before submitting. Paste your code into the placeholder at the top of the file. Review the Homework FAQ page, which contains instructions and a video of how to use the provided file. If you aren't sure how to use the tester or have any…arrow_forward
- Java: Write a complete method to create an array of random integers. Method Specification The method takes in three integer parameters: the array size, the lower bound, and the upper bound. The method also takes in a boolean parameter. The method creates and returns an integer array of the specified size that contains random numbers between the lower and upper bound., using these rules: The lower bound is always inclusive. If the boolean parameter is true, the upper bound is also inclusive. If the boolean parameter is false, the upper bound is not inclusive (meaning it is exclusive). If any of the parameters are invalid, null is returned. Driver/Tester Program I have provided you with a driver/tester program that you can use to test your code before submitting. Paste your code into the placeholder at the top of the file. I strongly recommend running this program before you submit your homework. The program is designed to help you catch common errors and fix them before submitting.…arrow_forwardbasic java please Write a void method named emptyBox()that accepts two parameters: the first parameter should be the height of a box to be drawn, and the second parameter will be the width. The method should then draw an empty box of the correct size. For example, the call emptyBox(8, 5) should produce the following output: ***** * * * * * * * * * * * * ***** The width of the box is 5. The middle lines have 3 spaces in the middle. The height of the box is 8. The middle columns have 6 spacesarrow_forward//Todo write test cases for SimpleCalculator Class // No need to implement the actual Calculator class just write Test cases as per TDD. // you need to just write test cases no mocking // test should cover all methods from calculator and all scenarios, so a minimum of 5 test // 1 for add, 1 for subtract, 1 for multiply, 2 for divide (1 for normal division, 1 for division by 0) // make sure all these test cases fail public class CalculatorTest { //Declare variable here private Calculator calculator; //Add before each here //write test cases here }arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education