Code:cin >> CAD; CAD = (0.98 * USD);
You get CAD then overwrite it with the following calc.
Anything times zero, which is what you set USD too, is equal to zero.
yeah i figured it was something like that i just dont know how to alter it
Code:cin >> CAD; CAD = (0.98 * USD);
You get CAD then overwrite it with the following calc.
Anything times zero, which is what you set USD too, is equal to zero.
yeah i figured it was something like that i just dont know how to alter it
CAD = (0.98 * USD);
Code:CAD = (0.98 * USD);
Will take the contents of USD, multiply it by 0.98, and store it in CAD. Is that what you want?
Yeah I think so.. I just have to write a code tht converts CAD to USD..which would be the opposite of what you just said I think.
How do you convert CAD into USD?
my professor gave us that 1CAD = 0.98USD was what we should use, even though its not up to date
And so if I gave you 100 CAD, how would you convert that into USD?
um multiply 100CAD by 0.98?
Yes, so in code you'd want to take the number of CAD multiply by 0.98 and store the result in a new variable. How would you write that in code?
ugh i dont know. this class is going to be the death of me.
0.98 * CAD = USD?
5 = x;
double USD = 0, CAD = 0;
cin >> CAD;
CAD = (0.98 * USD);
Ok, you have the math equation written correctly, but how does the assignment operator (=) work in C? Can you store the number 5 in the variable x by writing
Code:5 = x;
?
Code:double USD = 0, CAD = 0; cin >> CAD; CAD = (0.98 * USD);
Again - you ask the user to give a value for CAD.
Then you assign the result back into CAD with:
CAD = (.98 * USD)
... or ...
CAD = (.98 * 0)
... resulting in ...
CAD = 0
A little Algerbra should allow you to figure this out.
so that would be x = 5; am i right?
Yes, so you assign a value to a variable by putting the variable on the left and the value on the right.
Now you've read in the number of canadian dollars and stored it in CAD. You know that to convert to us dollars you need to multiply CAD by 0.98. So you want to take that result and store it in your USD variable.
So, convert my words into code. You know how to do it!
#include <iostream>
using namespace std;
#include <iomanip>
using std::setprecision;
int main ()
{
double USD, CAD;
cout << setprecision (2) << fixed;
cout << "Enter the amount of CAD: ";
cin >> CAD;
while (USD != 0)
CAD = 0.98 * USD;
USD = 0.98 *CAD;
cout << "$" << CAD << " CAD is equal to $" << USD << " USD" << endl;
return 0;
}
unfortunately i do not. my life sucks
CAD = (0.98 * USD);
[/COLOR]sweet baby jesus i think i got it.
----------
Code:#include <iostream> using namespace std; #include <iomanip> using std::setprecision; int main () { double USD, CAD; cout << setprecision (2) << fixed; cout << "Enter the amount of CAD: "; cin >> CAD; [B]while (USD != 0) CAD = 0.98 * USD; [/B] USD = 0.98 *CAD; cout << "$" << CAD << " CAD is equal to $" << USD << " USD" << endl; return 0; }
Yes you do. You have written
Code:CAD = (0.98 * USD);
which multiplies the value of USD by 0.98 and stores it in CAD. You want to multiple the value of CAD by 0.98 and store it in USD. How do you do that?
----------
You don't need what I've bolded.
aw yay! thank you so much for your help i cant believe i was being that dumb.
You'll get the hang of it.
#include <iostream>
using namespace std;
int main ()
{
int x = 4;
while ( x <=404 )
{
cout << x << endl;
x += 4;
}
return 0;
}
its literally like learning a whole new language!
im going to ask you a quick question while youre here..
the problem says "Write a C++ program to display the following sum:
4 + 8 + 12 + 16 + 20 + 24 +...+ 404
i dont understand how to get it to output as that, this is as close as i came:
Code:#include <iostream> using namespace std; int main () { int x = 4; while ( x <=404 ) { cout << x << endl; x += 4; } return 0; }
which obviously just displays every 4th number up to 404
#include <iostream>
using namespace std;
int main()
{
int sum = 0;
for (int x = 4; x<=404; x+=4)
sum += x;
cout << "Sum equals " << sum << endl;
return 0;
}
its literally like learning a whole new language!
im going to ask you a quick question while youre here..
the problem says "Write a C++ program to display the following sum:
4 + 8 + 12 + 16 + 20 + 24 +...+ 404
i dont understand how to get it to output as that, this is as close as i came:
Code:#include <iostream> using namespace std; int main () { int x = 4; while ( x <=404 ) { cout << x << endl; x += 4; } return 0; }
which obviously just displays every 4th number up to 404
----------
ACtually i think this works..
yay me?Code:#include <iostream> using namespace std; int main() { int sum = 0; for (int x = 4; x<=404; x+=4) sum += x; cout << "Sum equals " << sum << endl; return 0; }
mmm im unsure about that, but you never know! haha i just like the moment of glory when i run something and theres 0 errors and it actually does what i wantProgramming takes practice and dedication, but it'll come with time. Who knows maybe you'll end up really liking it and become a computer programmer
mmm im unsure about that, but you never know! haha i just like the moment of glory when i run something and theres 0 errors and it actually does what i want
mmm im unsure about that, but you never know! haha i just like the moment of glory when i run something and theres 0 errors and it actually does what i want