Q5. a) Write a java program to demonstrate the use of mutable objects to find the Perimeter of a rectangle using Point (8,2) .Perimeter = 2(length + breadth). b) Write a statement to include BigInteger in your program and write an example to convert int into BigInteger.
Q: class Line: '''write your codes below (don't forget to change the doc strings)''' def…
A: class Line(object): k=0 b=0 def __init__(self, k, b): self.k=k…
Q: // Step 1: Import the Java Scanner class /** * The Java program inputs the original cost for a sale,…
A:
Q: Click the four endpoints of the rectangles given in the java statements. 1. g.drawRect(600, 0, 200,…
A: drawRect(int x,int y,int width,int height) it is used to create rectangle in applet or in gui
Q: Consider the following application. Identify and correct any syntactic errors or omissions by…
A: Correcting the syntactic error or omitting by rewriting the line: 01 public Class Average;…
Q: Fix the Java code below: Make sure to have the right code indentation Make sure the "Main"…
A: Actually given code there was a problem with the main function and all the remaining code was…
Q: Assignment Write a program that moves a forester unit and a desert corps unit to a given target…
A: Assignment Write a program that moves a forester unit and a desert corps unit to a given target…
Q: (Emirp) An emirp (prime spelled backward) is a nonpalindromic prime number whose reversal is also a…
A: The Java software displays the first 100 emrip numbers, which are nonpalindromic numbers with a…
Q: Question: 2 Implement the design of the Laptop and Store classes so that the following code…
A: Algorithm: Start Create a class Store with laptops a list as static variable and name as instance…
Q: Draw the four endpoints of the rectangles given in the java statements. 1. g.drawRect(150, 200,…
A: 1. In java g.drawRect(int x,int y, int width ,int height) x,y is the first co-ordinate of rectangle…
Q: D: Write statements that do the following: 1. Set the value of s to 8 without using any of the…
A: Statement to set the value of 8 without using any of the objects. Increment s by 2 every time an…
Q: using paintComponent(Graphics g) Write a program in java that, for four points A, B, C and P, •…
A: Explanation: Inside the findDistance method, find the distance by using the following formula:…
Q: Q.3) write Java program that will draw horizontal line using the symbol & which consist of 7 and…
A: public class Main { public static void main(String args[]) { int n=7; for(int…
Q: A palindromic prime is any prime number that is also a palindrome. For example, 131 is a palindromic…
A: In this program, you need to display the first 100 palindromic prime numbers. So for this, first you…
Q: In java language Write a Rectangle class. A Rectangle has properties of width and length. You…
A: File name: "Rectangle.java" public class Rectangle { private double length; private…
Q: Use java to write a program which stores the string value “TREBOR EVIL NO WARTS” using a…
A: - We need to create a java program to provide the asked output using StringBuilder class.
Q: Write Java statements that finds the count of strings that are less than the String object str in an…
A: Please find the answer below :
Q: Lab04-06. Change the definition of the following constructor to use initialization instead of…
A: A function or method can be initiated by using the initializer list. The syntax is shown below.…
Q: Java Programming One day, Fred and his N friends were playing a card game in which each player…
A: Java Program for above : import java.util.Scanner; class Prog{ public static void main…
Q: (Population projection) The U.S. Census Bureau projects population based on thefollowing…
A: Program: //declaring the class public class Population { //defining the main method public…
Q: 4) In each below, a segment of Java code is given. Draw a picture that shows the final result of the…
A: Linked List: A linked list is a linear data structure that is basically a collection of nodes. These…
Q: Python Programming The Card Geme One day, Fred and his N flends were playing a card game in which…
A: As per the given problem statement we are required to develop a python code to help Fred flip the…
Q: Language: C++ Use the previously given files: Critter.h, Critter.cpp and testcritter. Expand…
A: Given:
Q: 13. Write a program that plays a simplified dice version of blackjack. Instead of selecting from a…
A: The Following Java Code contains 2 class Players.java Games.java
Q: Consider the following statements: T(x, y): "x eats y". A(x): "x is wise". S(x): "x is hungry".…
A: Answer: C
Q: OBJECT-ORIENTED PROGRAMMING. CS 102 Wednesday, 6 October, 2021 1. Write a Java program that creates…
A: code : - //import Scanner class for input import java.util.Scanner; public class Main{ public…
Q: 1)-Write a Java program that reads values for three sides of a triangle. The sides will form a…
A: Please give positive ratings for my efforts. Thanks. PROGRAM import java.util.Scanner; class…
Q: Write a Java code that creates a pong game where whenever the ball hits the paddles or the left and…
A: Algorithm: Create a Ball class It draws ball structure And also check ball collision with the…
Q: write java statement to shift the content of each cell of an integer array one place to the right,…
A: class RotateRight { public static void main(String[] args) { //Initialize array…
Q: Imagine a publishing company that markets both book and audiocassette versions of its work. Create a…
A: Actually, program is a executable software that runs on a computer.
Q: 4. Implement the following class diagram. Shape #color:String +Shope (color:String ) +getColor…
A: For implementing the given diagram as classes follow the below algorithm: Create class Shape:…
Q: Consider the dealerCars array that is full of references to Car objectsWrite Java code to count how…
A: Use a for loop to iterate over the given array and then keep on counting the Car instances which has…
Q: . Write a Java program to sort a numeric array and a string array.
A: SORTING - Sorting is the process of putting a list or a group of items in a specific order. Some…
Q: Question: 2 Implement the design of the Groceries and Buyer classes so that the following code…
A: I have the same implement program which I done few days and it more useful than this
Q: Draw the four endpoints of the rectangles given in the java statements. 1. g.drawRect(600, 0, 200,…
A: public void drawRect(int x, int y, int width, int height): draws a rectangle with the specified…
Q: D) Have the main method do the following: • Instantiate two instances of the Circle class with…
A: logic:- define circle class with attributes radius and Color. Inside this class define method…
Q: Write a C++ program. Write a program that will help an elementary school student learn…
A: Operators are the fundamental building blocks of all programming languages. Java, too, has a variety…
Q: Q.3) write Java program that will draw horizontal line using the symbol * which consist of 12 stars…
A: Write a JAVA program to draw a horizontal line that contains 12 '*'. Expected Output: ************…
Q: Write a Rectangle class. A Rectangle has properties of width and length. You construct a Rectangle…
A: Introduction of the Program: The Java Program uses default and parameterized constructor to…
Q: consider the following code snippet: class Comp{ int g; public: Comp0{g=-1;} Comp(int y){g=y;} };…
A: Const is a keyword that which only create a read only reference i.e defines a variable or pointer…
Q: ake screenshots Write a Java program to show how to widen a smaller size type to a larger size type
A: Converting a smaller type to a larger type size (automatically) is known as Widening Casting. byte…
Q: JAVA CODE PLS Rectangle by CodeChum Admin A rectangle can be formed given two points, the top left…
A: Answer :
Q: Problem 4) Suppose the following Course class is given: public class Course { private String…
A: If the evaluation of a logical expression exits even before the complete evaluation is done, it is…
Q: Imagine a publishing company that markets both books and audio-cassette versions of its works.…
A: // Publication class definition class Publication{ private: string title; float…
Q: cs101: Lab #5 Using Classes and Objects Part II 1. Write a program that computes the area of each…
A: Given:
Q: write Java program that will draw horizontal line using the symbol * which consist of 12 stars just…
A: A statement can be executed multiple times by using for loop in Java Syntaxfor(int i=0;i<n;i++){…
Q: A palindromic prime is any prime number that is also a palindrome. For example, 131 is a palindromic…
A: · Create a main class and required variable to solve the problem of palindromic prime.·…
Q: Java program, Create a class called Library with Accno, Callno, Title of the book, Author, Price of…
A: The java program will be created as follows: Create a class Library. Declare all the data members.…
Q: 4. Write a program that computes the area of a circular region (the shaded area in the diagram)…
A: Answer : CODE IN JAVA: Circle.java file: public class Circle { private double radius; public…
Q: (Java) Q 5,6 Explain the answer step-by-step . I want to understand how to do it so please include…
A: Given class name As Student and has two public member variables: A string called name and a double…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- Java - Encapsulation A rectangle can be formed given two points, the top left point and the bottom right point. Assuming that the top left corner of the console is point (0, 0), the bottom right corner of the console is point (MAX, MAX) and given two points (all “x” and “y” coordinates are positive), you should be able to draw the rectangle in the correct location, determine if it is a square or a rectangle, and compute for its area, perimeter and center point. To be able to do this, you should create a class Point (that has an x-coordinate and a y-coordinate). Also, create another class called Rectangle. The Rectangle should have 2 points, the top left and the bottom right. You should also implement the following methods for the Rectangle: display() - draws the rectangle on the console based on the samplearea() - computes and returns the area of a given rectangleperimeter() - computes and returns the perimeter of a given rectanglecenterPoint() - computes and returns the center point…Order check [15 points]. Write a program OrderCheck.java that takes four int command-line arguments w, x, y, and z. Define a boolean variable whose value is true if the four values are either in strictly ascending order (w < x < y < z) or strictly descending order (w > x > y > z), and false otherwise. Then, display the boolean variable value.NOTE 1: Do not use if statements on this program.NOTE 2: Assume that the inputs will always be integers.HangmanAA.java For this program, you will create the game Hangman. (If you are unsure of how to play Hangman, Google it.) The game will start by asking player 1 for a word or phrase (can be multiple words). Then player 1 will be asked how many missed guesses are allowed by player 2. Once this information is received, player 2 will take over. (Have the program print many blank lines of space so that player 2 can’t see what player 1 entered.) The instructions should be displayed for player 2 as well as the number of misses they’re allowed to make before they lose the game. The screen should also output dashes or underscores to represent each letter of player 1’s secret word/phrase. Player 2 should guess one letter at a time. Case should not matter. Typing x or X should give the same result. If that letter is present in the mystery phrase, then it should be displayed. (It will replace the dash/underscore in that spot. Spaces, punctuation, and all other non-alphabetic characters should…
- Create a class with [3][3] dimension and the java programshould display the magic square. Kindly explain each statement that you will use.2. Write a Java program that would resemble a payroll system. An input window which will accept the employee number and the number of days of rendered work. A 2d-arraylist that contains the employee number and the rate per day is to be searched and used to compute for the gross salary. Gross salary is computed by multiplying the number of days of rendered work by rate per day of the particular employee. If the gross salary computed is greater than 100,000 the tax is 20% of the gross salary, otherwise, the tax is 10%. Deduct the tax from the gross salary to get the net pay. Display the employee number, gross salary, tax deduction, and the net pay in an output window. Design your own input/output windows.Write a code in Java Programming Your task is to simulate a coffee shop using the observer pattern (do not use the deprecate one). The coffee shop serves two types of coffee: espresso and cappuccino. The shop has two baristas, EspressoBarista and CappuccinoBarista. EspressoBarista generates random espresso orders between 1 and 3 every 2 seconds, while CappuccinoBarista generates random cappuccino orders between 1 and 3 every 3 seconds. The UML design diagram is shown below. Property ChangeListenerfac Observablenerfacto Coffeeshop HashMap Sting, integer> ingredients ExpresssCartate The CoffeeShop class holds the current stock of ingredients and the CoffeeShop constructor initializes the count for each ingredient. The required ingredients for each type of coffee are as follows: • Espresso: 1 shot of espresso, 1 ounce of milk Cappuccino: 1 shot of espresso, 2 ounces of milk, 1 ounce of foam If an order cannot be fulfilled because there are not enough ingredients, a warning message…
- Write a Java program, using object- oriented programming concepts, that allows the user: 1- Enter the marks array, which contains the marks for 10 students. 2- Find the first repeating mark (Note: the mark should occur more than once, and the index of its first occurrence should be the smallest). 3- Find students who have higher marks (more than average marks). 4: Sort the students' marks in ascending order. 5: Add marks of two new students to the array.Use Java Implement a game of Pig where the user plays against a "hold at 20 or goal" computer player that rolls until a 1 ("pig") is rolled, or the turn total is greater than or equal to 20, or the score plus the turn total is greater than or equal to 100. The first player is chosen randomly. An empty input (i.e., Enter) indicates that the user wishes to roll. Any entered line of non-zero length indicates that the user wishes to hold. Before the game, randomly select which player the user will be, and print the line "You will be player #.", where # is the user's player number. Then, print an instruction line "Enter nothing to roll; enter anything to hold." Before each turn, print a line with "Player 1 score: " and player 1's score. Print another line with "Player 2 score: " and player 2's score. Finally, print a line with "It is player #'s turn.", where "#" is replaced by the current player number. Play starts with player 1 and then alternates. For each roll, print a line with…write java statement to shift the content of each cell of an integer array one place to the right, except for the content of the last cell, which should be moved into the cell with subscript 0. Thus for example, if the array looks like this: 0 1 2 3 4 5 2 9 3 7 then the array will be changed to look like this: 0 1 2 3 4 7 5 2 9 3
- Image binarization converts a greyscale or a coloured image to a black and white image. Assume that you are given a greyscale image with text as shown in Figure 2 below. Write the Java program to convert the greyscale image to a black and white image. You may set your own estimated threshold value. A VILLAGE OF MORMONS-Over seven hun- dred Mormons reached this city from New York May 15th, and tarried with us till the early train westward set off this morning. There were enough of them to constitute a good sized village. Figure 2: Greyscale Text Imagejava program that shows exact output as picture program that asks the user to enter a number to be tested for repeated digits. For each input number from the user, the program prints a table showing how many times each digit appears in the number. Let’s assume that the appearance of a digit will not be over 1000 times in the input. Make sure your table printout can align well. The program should terminate when the user enters a number that is less than or equal to 0. A sample output is shown in the attachment.PLEASE HELP ME FIND THE JAVA CODE FOR THIS PROBLEM 2. Rectangle by CodeChum Admin A rectangle can be formed given two points, the top left point and the bottom right point. Assuming that the top left corner of the console is point (0,0), the bottom right corner of the console is point (MAX, MAX) and given two points (all "x" and "y" coordinates are positive), you should be able to draw the rectangle in the correct location, determine if it is a square or a rectangle, and compute for its area, perimeter and center point. To be able to do this, you should create a class for a point (that has an x-coordinate and a y-coordinate). Also, create another class called Rectangle. The Rectangle should have 2 points, the top left and the bottom right. You should also implement the following methods for the Rectangle: display() - draws the rectangle on the console based on the sample area() - computes and returns the area of a given rectangle perimeter() - computes and returns the…