Hi. I am making a really simple program to refresh my knowledge in java (which is obviously needed). When I click the screen, I want a bullet to appear in the center and move towards the point I clicked. Right now, when I click on the left half the bullet will go either straight up or directly left, and if I click the right half then it just stays in the center of the screen. I have two classes (plus a third main class): **ShooterPanel class** package shooter; import java.awt.Color; import java.awt.Graphics; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.*; public class …

Member Avatar
Member Avatar
+0 forum 2

I have the code for the first part of a problem, which is to write a program that reads an angle x (in radians) from the keyboard. Then, in a function, compute the cosine of the angle using the first five terms of this series. Print the value computed along with the value of the cosine computed using the C++ library function. However, I need help modifying the program so that the approximation uses terms from the series as long as the absolute value of a term is greater than 0.0001. Also, print the number of terms used in the …

Member Avatar
Member Avatar
+0 forum 8

I'm trying to create a program that computes the values of cos using the Taylor Series as long as the absolute value of a term is greater than 0.0001 and prints the number of terms used in the series approximation. My code is the following and as of right now I am getting the wrong result. Please help me fix it! I've spent hours trying to figure it out and don't know what to do. Enter the angle in radians: 3.14 There were 8 numbers of terms used in the series approximation. The calculated cosine of 3.14 is 0.00499852 The …

Member Avatar
Member Avatar
+0 forum 12

My teacher wants me to write a function called double cos(float); to compute the cos of an angle (given in radians) using the Taylor series shown. Your function should find the value of the cos for ANY angle (preferred) or at least angles up to 2 PI (Hint: if you can do the later, the former should be easy) to a precision of 4 decimal places (within 0.00005). You should put the function cos() in the file called trig.c. You can use the function pos_power() in your exponent.c from Lab 6 and Hw 4, and you should write functions for …

Member Avatar
Member Avatar
+0 forum 5

I am currently working on a project in which I need to check the similarity between images... I have started of trying the cosine similarity.. the formula available online needed to be modified since it was only for text and in images the 1st pixel of one image will have to be checked with every pixel of the next. I tried the following code in matlab but it gives no output.. i have no idea if i am even remotely correct.. [CODE] x1=imread('C:\Program Files\MATLAB\R2009a\image classes\flowers\f1.jpg'); x2=imread('C:\Program Files\MATLAB\R2009a\image classes\flowers\f2.jpg'); %[m1 n1]=size(x1); %[m2 n2]=size(x2); for i=1:256 for j=1:256 if(x1(i,j)==0) x1(i,j)=1; end if(x2(i,j)==0) …

Member Avatar
Member Avatar
+0 forum 1

We are required to make a c++ program to determining the cos of x by using the taylor series. i have made my program and it works pretty good but we are also required to stop the loop after the terms in the taylor series gets lower than .0001. any suggestions? (Taylor Series for cos = 1 - x^2/2! + x^4/4!...) [CODE] #include <iostream> #include <cmath> using namespace std; double fac(int n) { double f=n; while (--n)f*=n; return f; } int main() { double long x; cout << "Enter Angle in Radians: " << endl; cin >> x; double cos(0.0); …

Member Avatar
Member Avatar
+0 forum 1

[CODE] class character1{ public static void main (String args[]){ float a,b; a=Integer.parseInt (args[0]); b=(float)Math.acos(a*(180/3.14)); System.out.println (b); } }[/CODE] the above program isn't working when entering angle other than 1 , why ?

Member Avatar
Member Avatar
+0 forum 7

The End.