A deque (short for double-ended queue, but pronounced “deck”) is an abstract data type that supports adding and removing at both the front and back. So, at a bare minimum, a deque has four operations: addFront(), removeFront(), addBack(), removeBack(). Suppose you have a deque D containing the numbers (1, 2, 3, 4, 5, 6, 7, 8), in this order. Suppose further that you have an initially empty queue Q. Give pseudo-code description of a method that uses only D and Q (and no other variables or objects) and results in D storing the elements (1, 2, 3, 5, 4, 6, 7, 8), in this order.
In: Computer Science
Objective: Using Java coding language, complete each "TO-DO" section for the following classes.
Shape code (for reference, nothing to complete here):
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.io.RandomAccessFile;
public abstract class Shape extends Rectangle {
public int id;
public Color color;
public int xSpeed, ySpeed;
public Shape(int id, int x, int y, int width, int
height, Color color, int xSpeed, int ySpeed) {
super(x,y,width,height);
this.id = id;
this.color = color;
this.xSpeed = xSpeed;
this.ySpeed = ySpeed;
}
public abstract void move(int screenWidth, int
screenHeight);
public abstract void draw(Graphics g);
public abstract void save(RandomAccessFile raf) throws
Exception;
}
Ball code:
import java.awt.Color;
import java.awt.Graphics;
import java.io.RandomAccessFile;
public class Ball extends Shape {
public Ball(int id, int x, int y, int size, Color
color, int xSpeed, int ySpeed) {
super(id, x, y, size, size, color,
xSpeed, ySpeed);
}
@Override
public void move(int screenWidth, int screenHeight)
{
x += xSpeed;
y += ySpeed;
if(x > screenWidth) x =
-width;
else if(x + width < 0) x =
screenWidth;
if(y > screenHeight) y =
-height;
else if(y + height < 0) y =
screenHeight;
}
@Override
public void draw(Graphics g) {
g.setColor(color);
g.fillOval(x, y, width,
height);
g.setColor(Color.BLACK);
g.drawOval(x, y, width,
height);
}
// TO-DO: Write the code that
saves out the type of object (Ball)
//
and all data about the box ("Ball", id, x, y, width, height,
color,
//
xSpeed, and ySpeed)
@Override
public void save(RandomAccessFile raf) throws
Exception {
// Note, when saving color you will
save it as an int: color.getRGB()
}
}
Box code:
import java.awt.Color;
import java.awt.Graphics;
import java.io.RandomAccessFile;
// is-a
public class Box extends Shape {
public Box(int id, int x, int y, int size, Color
color, int xSpeed, int ySpeed) {
super(id, x, y, size, size, color,
xSpeed, ySpeed);
}
@Override
public void move(int screenWidth, int screenHeight)
{
x += xSpeed;
y += ySpeed;
if(x > screenWidth) x =
-width;
else if(x + width < 0) x =
screenWidth;
if(y > screenHeight) y =
-height;
else if(y + height < 0) y =
screenHeight;
}
@Override
public void draw(Graphics g) {
g.setColor(color);
g.fillRect(x, y, width,
height);
g.setColor(Color.BLACK);
g.drawRect(x, y, width,
height);
}
// TO-DO: Write the code that
saves out the type of object (Box)
//
and all data about the box ("Box", id, x, y, width, height,
color,
//
xSpeed, and ySpeed)
@Override
public void save(RandomAccessFile raf) throws
Exception {
// Note, when saving color you will
save it as an int: color.getRGB()
}
}
In: Computer Science
XYZ purchased a machine 5 years ago at a cost of $95,000. The machine had an expected life of 10 years at the time of purchase, and it is being depreciated by the straight-line method by $9,500 per year. If the machine is not replaced, it can be sold for $11,000 at the end of its useful life. A new machine can be purchased for $170,000, including installation costs. During its 5-year life, it will reduce cash operating expenses by $55,000 per year. Sales are not expected to change. At the end of its useful life, the machine is estimated to be worthless. MACRS depreciation will be used and the machine will be depreciated over its 3-year class life rather than its 5-year economic life; so the applicable depreciation rates are 33%, 45%, 15%, and 7%. The old machine can be sold today for $65,000. The firm's tax rate is 45%. The appropriate WACC is 17%.
a. If the new machine is purchased, what is the amount of the initial cash flow at Year 0?
b. What are the incremental cash flows that will occur at the end of Years 1 through 5?
c. What is the NPV of this project? Should the old machine be replaced? Explain.
Please mention the keys step by step that were used so I can solve it, ON FINANCIAL CALCULATOR BA II PLUS, otherwise your solution is of no value! NO EXCEL ANSWERS!
In: Finance
Year 1 Year 2 Year 3 Year 4
Unit sales 1,000 1,500 2,000 3,000
Selling price per unit $10 $12 $15 $18
Please calculate Dexter’s projected or proforma sales.
Year 1 Year 2 Year 3 Year 4
Annual fixed costs $2,000 $2,100 $2,200 $2,400
Variable costs per unit $5 $6 $8 $9
Assuming these are all the costs for Dexter. Please calculate Dexter’s projected or proforma profit.
In: Accounting
Explore the needed sources and Identify (One example) of how chromatography (e.g. TLC, HPLC) has been used to determine the chemical components of a sample.
For the example which you have chosen, remember to mention the following:
-List the chemical components identified.
- Include details of the mobile and stationary phases and the conditions used to affect the resolution of the components (e.g., flow rate, pressure, temperature,...).
In: Chemistry
Explain in details what are the solar resources (where? , how much? , what can change the availability of sun light like dust, fog, etc..) mention other examples too of what can change the availability other than dust, fog.
I want detailed answers please with the references if you have. This is for my presentation
Solar cells is not the core topic of this questions.
In: Physics
Your experts solved my question:
Describe steps that can be taken to develop a healthy menu for the
following groups:
Infants
Toddlers
Children
Be sure to mention any food safety issues as well as listing special menu
items for diverse cultures and those children with special dietary
concerns. I would appreciate it if you would send the resources
used to answer the questions.
In: Nursing
In the Week 4 experiment, an additional “wash” step was added to the extraction protocol. Discuss the difference between the extraction step (ethyl acetate extraction of aqueous caffeine) and the wash step (dilute base wash of the ethyl acetate layers). Your answer should mention what is happening to the caffeine and impurities in each step as well as the intermolecular forces involved in the process explain fully
In: Chemistry
(2) Juhaina and Assma are two friends who are considering starting a fashion designer business together. They are unsure as to which business structure would be more appropriate for their business and they have approached you for advice. Write a Memo advising them on which business structure they should implement and why-250 words .
note: mention the advantages and disadvantages to each type of business entity.
In: Accounting
Determine why information security is so important in healthcare by analyzing at least two different types of safeguards for data and elaborate on what standards are looked at for each. Also, identify the types of facilities these safeguards can be used in and what are the expectations. Please try not to duplicate your classmates’ answers. There may be several different standards for each safeguard but you are required to mention at least two.
In: Computer Science