-
Grand Future Air Dried Beef Dog Food
Air Dried Dog Food | Real Beef

Carnivore Diet for Dogs

Go Back   Automotive Forums Car Chat > Coffee Break (Off-Topic) > COMPLETELY off-topic
Register FAQ Community
COMPLETELY off-topic Talk about anything other than cars. But you can't be mad and angry in this forum!
Reply Show Printable Version Show Printable Version | Subscription Subscribe to this Thread
 
Thread Tools
  #1  
Old 05-18-2003, 02:11 PM
Raging Bull's Avatar
Raging Bull Raging Bull is offline
AF Enthusiast
 
Join Date: Mar 2002
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Raging Bull
C++ Help

hey guys, any of you know whats wrong with this and y its not wrking.

CHeers, RB

//Exercise 12.4
#include <fstream.h>
#include <iomanip.h>
#include <iostream.h>

double Engine_Speed;
double s[15];
double t[15][10];
int i, j, Throttle;

double Torque(double Engine_Speed, int Throttle)
{
// Looping through speed array until the correct value is found
for (i=0; i<15; i++)
{
// Is the speed array value speed[i] greater than the required speed
if (s[i] > Engine_Speed)
{
// If yes, jump out of the loop
break;
}
if (s[i] > s[14])
i = 14;
}
// Interpolating between values to find the torque at the required speed
//double Torque;
double Torque = (t[i-1][Throttle] + ((t[i][Throttle] - t[i-1][Throttle])*(Engine_Speed - s[i-1]))
/ (s[i] - s[i-1]));
return Torque;
}


// Main program
int main()
{
ifstream Input_File("Torque.dat", ios::in | ios::nocreate);
if (!Input_File)
{
cerr << "Failed " << endl;
}


for (i=0; i<=14; i++) // For each row i (Engine speed)
{
Input_File >> s[i];
for (j=0; j<=9; j++) // For each row j (Throttle setting)
{
Input_File >> t[i][j];

}
}
Input_File.close();

cin >> Throttle;
cin >> Engine_Speed;

Torque(Engine_Speed, Throttle);

cout << "speed " << s[0];
cout << "\n" << "throttle " << t[0][0] << "\n \n \n";

cout << Torque;
return 0;
}



*** Torque.dat File ***

0.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0
78.5 1.6 13.9 26.1 38.4 50.7 63.0 75.3 87.6 99.9 112.2
104.7 -0.7 12.5 25.7 38.9 52.1 65.2 78.4 91.6 104.8 118.0
130.9 -2.9 11.1 25.1 39.1 53.1 67.1 81.1 95.1 109.1 123.1
157.1 -5.1 9.7 24.5 39.3 54.1 68.9 83.7 98.5 113.3 128.1
209.4 -9.5 6.7 22.9 39.2 55.4 71.6 87.8 104.1 120.3 136.5
261.8 -14.0 3.5 20.9 38.4 55.8 73.3 90.7 108.2 125.6 143.1
314.2 -18.4 0.1 18.5 37.0 55.5 74.0 92.4 110.9 129.4 147.9
366.5 -22.8 -3.5 15.8 35.0 54.3 73.6 92.9 112.2 131.5 150.8
418.9 -27.3 -7.4 12.6 32.5 52.4 72.3 92.2 112.1 132.0 152.0
471.2 -31.7 -11.5 8.8 29.0 49.2 69.5 89.7 109.9 130.2 150.4
523.6 -36.1 -15.6 5.0 25.5 46.1 66.6 87.2 107.7 128.3 148.8
576.0 -40.6 -20.1 0.4 20.8 41.3 61.8 82.3 102.7 123.2 143.7
628.3 -45.0 -24.6 -4.2 16.2 36.6 56.9 77.3 97.7 118.1 138.5
680.7 -49.4 -29.4 -9.4 10.6 30.6 50.6 70.6 90.6 110.6 130.6

__________________
Born to Drive a Lamborghini
Reply With Quote
  #2  
Old 05-18-2003, 03:08 PM
Marco_Wrc Marco_Wrc is offline
Rally Fan
 
Join Date: Jan 2002
Posts: 593
Thanks: 0
Thanked 0 Times in 0 Posts
How can we help you if you don't tell us what it should do.
Reply With Quote
  #3  
Old 05-18-2003, 03:44 PM
Marco_Wrc Marco_Wrc is offline
Rally Fan
 
Join Date: Jan 2002
Posts: 593
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, normally I don't dive into other's code, but I did this time.

You call the function Torque:
Torque(Engine_Speed, Throttle);

Then you want output from that function:
cout << Torque;

But, that doesn't work because:
The function torque returns a double. You need to print that double, not print the function Torque.

So, to fix it you can assign the double to a variable:
double torq = Torque(Engine_Speed, Throttle);
cout << torq;

Or print the output from Torque directly:
cout << Torque(Engine_Speed, Throttle);

If you do it the way you do: cout << Torque; You'll print out the memory address of the function Torque.
Reply With Quote
  #4  
Old 05-18-2003, 05:06 PM
Raging Bull's Avatar
Raging Bull Raging Bull is offline
AF Enthusiast
Thread starter
 
Join Date: Mar 2002
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Raging Bull
cheers marco, appreciate the help. Something so simple bin given me grief all night. Cheers again, ill remember you!!!
__________________
Born to Drive a Lamborghini
Reply With Quote
 
Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with new car audio; Cade.Garrett Car Audio 2 07-02-2009 01:32 PM
I need help!! Cade.Garrett Car Buying Q&A 1 06-04-2009 08:07 PM
jdm h22 help sanchezjarodsdad JDM Motor & Parts info/chat 4 04-09-2009 06:14 PM
97 ram 1500 sport 4x4 tranny problems HELP ME! tabes Ram Pickup | Ram SRT10 3 03-14-2009 09:56 AM
3.4L 1996 Cutlass Supreme Help please!!! Zca62783 Cutlass Series 0 02-14-2009 04:27 PM

Reply

POST REPLY TO THIS THREAD

Go Back   Automotive Forums Car Chat > Coffee Break (Off-Topic) > COMPLETELY off-topic


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -5. The time now is 02:50 PM.

Community Participation Guidelines | How to use your User Control Panel

Powered by: vBulletin | Copyright Jelsoft Enterprises Ltd.
 
 
no new posts