Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i need help doing project #4. with this java project i am trying to create a dra

ID: 3530846 • Letter: I

Question

i need help doing project #4.with this java project i am trying to create a drawing panel of a projectile motion of the size 420 x 220. with an intial velocity of 30 meters per second, and angle of 50 degrees, and ten steps. modifying the code below and putting it into a drawing panel to draw a projectile.

code must work, must display all of the above, and actually display a projectil motion in a java darwing panel

to get full points.

thanx


_____________________________________________________________________________________

here is the projectile motion code:

Explanation / Answer

public class Frame extends JFrame { private JPanel mainPanel; private JLabel title; private JLabel speedyholder; private int xpos=50,ypos=300,width=40,height=40; private int p1x,p1y,p2x,p2y; double dp1p2; double timepressed,timereleased; double mtopixels= 3779.527559; double g= 9.8*mtopixels; // 1 pixel = 0.026458333 cm = 0.0002645833 m public Frame(){ Simulation(); mainPanel.addMouseListener(new MouseHandler()); mainPanel.addMouseMotionListener(new MouseHandler()); } private void Simulation(){ mainPanel = new JPanel(); title = new JLabel(); speedyholder = new JLabel(); speedyholder.setBounds(xpos, ypos, width, height); mainPanel.setLayout(null); mainPanel.setBackground(new java.awt.Color(255, 255, 255)); title.setFont(new java.awt.Font("Rockwell", 1, 18)); title.setText("Speedy Training Session"); title.setBounds(250,10,230,40); speedyholder.setIcon(new javax.swing.ImageIcon(getClass().getResource("speedy.png"))); mainPanel.add(title); mainPanel.add(speedyholder); add(mainPanel); getSpeed(); getTheta(); getMaximumHeight(); getRange(); while((xpos=ypos-(getMaximumHeight()))){ ypos= (int) (Math.tan(getTheta())*xpos - g*xpos*xpos/(2*getSpeed()*getSpeed()*Math.cos(getTheta())*Math.cos(getTheta()))); xpos= xpos+1; speedyholder.setBounds(xpos, ypos, width, height); } pack(); } private double getRange() { double R=(2*getSpeed()*getSpeed()*Math.sin(getTheta())*Math.cos(getTheta()))/g; return R; } private double getMaximumHeight() { double H= (getSpeed()*getSpeed()*Math.sin(getTheta())*Math.sin(getTheta()))/(2*g); return H; } private double getTheta() { double thetaRadians= Math.atan((double)(Math.abs(p1y-p2y))/(double)(p2x-p1x)); return thetaRadians; } private double getSpeed() { dp1p2= (long)(Math.sqrt(Math.pow(p2x - p1x,2) + Math.pow(p1y-p2y, 2))); double speed= dp1p2/((timereleased-timepressed)*Math.pow(10, -3)); return speed; } private class MouseHandler implements MouseListener, MouseMotionListener { @Override public void mousePressed(MouseEvent arg0) { timepressed= System.currentTimeMillis(); if(arg0.getX()>=xpos && arg0.getX()ypos && arg0.getY()