I need to write a program that asks for the input of variables and one variable must be entered as "?", but I cannot get the program to use "?" at all. Also, I don't know how to create a driver function. Once I get the "?" input working, will the driver function just essentially be the equation I am given? Any help would be appreciated.

Recommended Answers

All 6 Replies

I need to write a program that asks for the input of variables and one variable must be entered as "?", but I cannot get the program to use "?" at all. Also, I don't know how to create a driver function. Once I get the "?" input working, will the driver function just essentially be the equation I am given? Any help would be appreciated.

The answers depend completely on
* What you need to input
* How you are allowed to input it
* What the definition of 'driver' is to your instructor/boss
* What you need to accomplish

Unless you give more information, it is really difficult to understand your problem.

For the program to understand a question mark, you would need to use an escape sequence.'\?'

Some more info on escape sequences

This is mostly meant for C.

The equation given to me is H = [kA(T2-T1)]/ X.
The instructions are Develop a driver function that interacts with the user in the following way:
Define a function for each variable in the formula. For example, function calcH would compute the rate of heat transfer, calcK would figure the coefficient of thermal conductivity, calcA would find the cross-sectional area, and so on. Respond to the prompts with the data known. For the unknown quantity, enter a question mark (?).

here is what I have so far

#include <iostream>
using namespace std; 

int main()
{
double H, k, A, X, T2, T1, calcH, calcT2, calcT1, calcX, calcA, calck;
cout << "Please enter the value of H" << endl;
cin >> H;
cout << "Enter the value of k" << endl;
cin >> k;
cout << "Enter the value of A" << endl;
cin >> A;
cout << "Enter the value of X" << endl;
cin >> X;
cout << "Enter the value of T2"<< endl;
cin >> T2;
cout << "Enter the value of T1"<< endl;
cin >> T1;

calcH = (k * A * (T2-T1)) / X;
calcT2 = ((H * X)/(k*A)) + T1;
calcT1 = ((H*X)/(k*A)) + T2;
calck = ((H*X)/(A* (T2-T1)));
calcA = ((H*X)/(k*(T2-T1)));
calcX = (k*A * (T2-T1))/H;

cout << "The rate of transfer is " << H << " watts." << endl;
cout << "The coefficient of the thermal conductivity is " << k << endl;
cout << "The cross sectional area is " << A << " m^2." << endl;
cout << "The temperature on one side of the conductor is " << T1 << " kelvin." << endl;
cout << "The temperature on the other side of the conductor is " << T2 << " kelvin." << endl;
cout << "The thickness of the conductor is " << X << " meters." << endl;
}
commented: for effort shown +1

You seem to be doing quite well by yourself. What help do you need?

If your input statement requires a number (double or int) you cannot enter a '?'.

You need to input a string, test the data for '?' or number. If number, translate it from string to value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.