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

can someone help me compile this code, and make it where it does the following:

ID: 3530857 • Letter: C

Question

can someone help me compile this code, and make it where it does the following: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



/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

//package frame.pkgextends.jframe;


import java.awt.event.MouseEvent;

import java.awt.event.MouseListener;

import java.awt.event.MouseMotionListener;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;


/**

*

* @author Owner

*/

public class FrameExtendsJFrame {


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<= getRange()+xpos) && (ypos>=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()<xpos+width && arg0.getY()>ypos && arg0.getY()<ypos+height)

System.out.println("You clicked on Speedy at " + arg0.getX() + "," + arg0.getY());

p1x=arg0.getX();

p1y=arg0.getY();


}


@Override

public void mouseReleased(MouseEvent arg0) {

timereleased= System.currentTimeMillis();

System.out.println("You released at " + arg0.getX() + "," + arg0.getY());

p2x=arg0.getX();

p2y=arg0.getY();

}


@Override

public void mouseDragged(MouseEvent arg0) {

// TODO Auto-generated method stub


}


@Override

public void mouseMoved(MouseEvent arg0) {

// TODO Auto-generated method stub


}


@Override

public void mouseClicked(MouseEvent arg0) {

// TODO Auto-generated method stub


}


@Override

public void mouseEntered(MouseEvent arg0) {

// TODO Auto-generated method stub


}


@Override

public void mouseExited(MouseEvent arg0) {

// TODO Auto-generated method stub


}


}


public static void main(String[] args) {

Frame mainFrame = new Frame();

mainFrame.setVisible(true);

mainFrame.setDefaultCloseOperation(EXIT_ON_CLOSE);

mainFrame.setLocationRelativeTo(null);

mainFrame.setSize(800, 400);

mainFrame.setResizable(false);


}

}

Explanation / Answer

It is getting compiled perfectly on my lappy

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote