First Program :
This program has no errors, but when i run it in consol it will just let me put in my name and then it will shoot everything up not letting me put in anymore of the numbers. So basically it lets me put my name in then does the whole program itself without any of the other information given.
Heres the screen shot of what im talking about :
http://i43.tinypic.com/e9zrx4.jpg
Here is the code :
#include <iostream>
#include <cstdlib>
using namespace std;
int main ()
{
cout << " Please enter your name : ";
char name;
cin >> name;
cout << " Please enter hours worked and minutes ";
double hours_worked;
cin >> hours_worked;
cout << " Please enter your hourly wage : ";
double hourly_wage;
cin >> hourly_wage;
int wage;
if (hours_worked < 40)
{
wage = (40 - hours_worked) * (hourly_wage * (hourly_wage / 2));
}
else
{
wage = hours_worked * hourly_wage;
}
cout << " Employe Name : " << name << "\n";
cout << " Hourse Worked : " << hours_worked << "\n";
cout << " Hourly Wage : " << hourly_wage << "\n";
cout << " Money Earned : " << wage << "\n";
return 0;
}
Now to the second program :
This program is giving me errors. I have copied the formula's down from our book where our teacher showed us to do it. But the formula is giving me the errors. It keeps showing "Call of overload 'pow(int&, int)' is ambiguous " ... For the life of me i dont know what is going on. Im just getting into programming and i dont know at all what this means.
Here is the code :
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main ()
{
cout << " Please enter a, b, and c (example 5 4 2) : ";
int a;
int b;
int c;
cin >> a >> b >> c;
cout << " Please enter a, b, and c (example 5 4 2) : ";
int a1;
int b1;
int c1;
cin >> a1 >> b1 >> c1;
cout << " Please enter a, b, and c (example 5 4 2) : ";
int a2;
int b2;
int c2;
cin >> a2 >> b2 >> c2;
int root1;
int root2;
double disc1 = pow(b, 2) - 4.0 * a * c;
root1 = (-b + sqrt(disc1)) / (2.0 * a);
root2 = (-b - sqrt(disc1)) / (2.0 * a);
int root3;
int root4;
double disc2 = pow(b2, 2) - 4.0 * a2 * c2;
root3 = (-b2 + sqrt(disc2)) / (2.0 * a2);
root4 = (-b2 - sqrt(disc2)) / (2.0 * a2);
int root5;
int root6;
double disc3 = pow(b2, 2) - 4.0 * a2 * c2;
root5 = (-b2 + sqrt(disc3)) / (2.0 * a2);
root6 = (-b2 - sqrt(disc3)) / (2.0 * a2);
cout << root1 << root2 << root3 << root4 << root5 << root6;
return 0;
}
If anyone could help me out that would be much appreciated
Thanks, Nathan

New Topic/Question
Reply



MultiQuote





|