Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C++ building a sin() table for calculation

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
wylun
Expert Cheater
Reputation: 0

Joined: 27 Jun 2006
Posts: 101

PostPosted: Thu May 14, 2009 2:15 pm    Post subject: C++ building a sin() table for calculation Reply with quote

Description:

For this assignment, you will be building a sin() table, and then using the sin() table to perform some calculations.


Task:

Create a C++ program that will do the following:
a) Create and initialize a sin() table. The size of this table should be 360, with each element of the table storing the sin() value. Hence, the index into the array represents degrees.
b) Prompt the user for 2 numbers which represents a vector using Polar coordinates.
c) Convert this Polar coordinate into Cartesian coordinate in the following way:
i. Using the sin() table you created, determine the Y-coordinate of this Polar coordinate.
ii. Once you have the Y-coordinate, use Pythagoras’ theorem to determine the X-coordinate.
iii. Output the Cartesian coordinate that you just computed with an appropriate message.

E.g The Polar coordinates you enter 10@30 degrees
has Cartesian coordinates (5, 8.6)

d) The program should repeat this process of allowing the user to input 2 numbers and converting them into Cartesian coordinates. However, if the input numbers are -99, -99, the program should exit with an appropriate message.


Code:
#include <iostream>
#include <math.h>
using namespace std;

double sin_table[360];
double x, y;
void main()
{
   for(int i = 0; i < 360; i++)
   {
      sin_table[ i ] = sin( i * (3.142/180));
    }
   
   float mag, angle;
   int st = 5;
   
   do
   {
   cout << " Please enter -99 into both input to exit the program "<<endl<<endl;
   cout << " Please enter 1st number for magnitude :";
   cin >> mag;
   cout << " Please enter 2nd number for degrees :";
   cin >> i;
   cout << endl<<endl;

   
   
   // program will start calculate if both key in not -99
   if ( mag != -99 && angle != -99 )
   {
      
      // do the calculation here
      y = mag * sin_table[ i ];
      x = sqrt(pow(mag,2) - pow(y,2));
      
      
      cout << " The Program will ask for input again in few second "<<endl;
      // server as time count down to restart the whole program
      for ( int i=0; i<99 ; i++ ){
         for (int y=0; y<999 ; y++){
            for(int a=0; a<999; a++){};
         };};
      // screen clear
      system("cls");
   }

   
   
   //when the magnitude and angle both equal as -99, the program will go off
   } while(mag != -99 && angle != -99);

   cout << "y = " << y << endl;
   cout << "x = " << x << endl;
   cout << "The Cartesian coordinate for the Polar is " << y << "," << x << endl;

   cout << "Thank you for using the program " << endl;
   cout << "The program going to end now " << endl;
   cout << endl;
   

   return;
}


What is my programme problems? anyone help me pls! Urgent

_________________


OWE REV 791 ,REV800,REV822,REV833
(quit maple) Currently playing MaplePrivateServer.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu May 14, 2009 5:03 pm    Post subject: Reply with quote

duplicate thread.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites