Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 29, 2012, 06:25 PM   #76
oxshannon
Thread Starter
macrumors regular
 
Join Date: Jan 2012
Quote:
Originally Posted by lloyddean View Post
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
oxshannon is offline   0 Reply With Quote
Old Jan 29, 2012, 06:29 PM   #77
mobilehaathi
macrumors 601
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: The Anthropocene
Quote:
Originally Posted by oxshannon View Post
yeah i figured it was something like that i just dont know how to alter it
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?
__________________
The true way is along a rope that is not spanned high in the air, but only just above the ground. It seems intended more to cause stumbling than to be walked along.
mobilehaathi is offline   0 Reply With Quote
Old Jan 29, 2012, 06:32 PM   #78
oxshannon
Thread Starter
macrumors regular
 
Join Date: Jan 2012
Quote:
Originally Posted by mobilehaathi View Post
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.
oxshannon is offline   0 Reply With Quote
Old Jan 29, 2012, 06:34 PM   #79
mobilehaathi
macrumors 601
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: The Anthropocene
Quote:
Originally Posted by oxshannon View Post
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?
__________________
The true way is along a rope that is not spanned high in the air, but only just above the ground. It seems intended more to cause stumbling than to be walked along.
mobilehaathi is offline   0 Reply With Quote
Old Jan 29, 2012, 06:35 PM   #80
oxshannon
Thread Starter
macrumors regular
 
Join Date: Jan 2012
Quote:
Originally Posted by mobilehaathi View Post
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
oxshannon is offline   0 Reply With Quote
Old Jan 29, 2012, 06:36 PM   #81
mobilehaathi
macrumors 601
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: The Anthropocene
Quote:
Originally Posted by oxshannon View Post
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?
__________________
The true way is along a rope that is not spanned high in the air, but only just above the ground. It seems intended more to cause stumbling than to be walked along.
mobilehaathi is offline   0 Reply With Quote
Old Jan 29, 2012, 06:38 PM   #82
oxshannon
Thread Starter
macrumors regular
 
Join Date: Jan 2012
Quote:
Originally Posted by mobilehaathi View Post
And so if I gave you 100 CAD, how would you convert that into USD?
um multiply 100CAD by 0.98?
oxshannon is offline   0 Reply With Quote
Old Jan 29, 2012, 06:39 PM   #83
mobilehaathi
macrumors 601
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: The Anthropocene
Quote:
Originally Posted by oxshannon View Post
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?
__________________
The true way is along a rope that is not spanned high in the air, but only just above the ground. It seems intended more to cause stumbling than to be walked along.
mobilehaathi is offline   0 Reply With Quote
Old Jan 29, 2012, 06:41 PM   #84
oxshannon
Thread Starter
macrumors regular
 
Join Date: Jan 2012
Quote:
Originally Posted by mobilehaathi View Post
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?
oxshannon is offline   0 Reply With Quote
Old Jan 29, 2012, 06:43 PM   #85
mobilehaathi
macrumors 601
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: The Anthropocene
Quote:
Originally Posted by oxshannon View Post
ugh i dont know. this class is going to be the death of me.

0.98 * CAD = 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;
?
__________________
The true way is along a rope that is not spanned high in the air, but only just above the ground. It seems intended more to cause stumbling than to be walked along.
mobilehaathi is offline   0 Reply With Quote
Old Jan 29, 2012, 06:58 PM   #86
lloyddean
macrumors 6502a
 
Join Date: May 2009
Location: Des Moines, WA
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.
lloyddean is offline   0 Reply With Quote
Old Jan 29, 2012, 07:01 PM   #87
oxshannon
Thread Starter
macrumors regular
 
Join Date: Jan 2012
Quote:
Originally Posted by mobilehaathi View Post
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;
?
so that would be x = 5; am i right?

----------

Quote:
Originally Posted by lloyddean View Post
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.
REason number 1 why I took a programming course as my math elective: i suck at algebra.

can i set it so that USD > 0? is it possible to just replace the equals sign with >? SO CONFUSING
oxshannon is offline   0 Reply With Quote
Old Jan 29, 2012, 07:07 PM   #88
mobilehaathi
macrumors 601
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: The Anthropocene
Quote:
Originally Posted by oxshannon View Post
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!
__________________
The true way is along a rope that is not spanned high in the air, but only just above the ground. It seems intended more to cause stumbling than to be walked along.
mobilehaathi is offline   0 Reply With Quote
Old Jan 29, 2012, 07:12 PM   #89
oxshannon
Thread Starter
macrumors regular
 
Join Date: Jan 2012
Quote:
Originally Posted by mobilehaathi View Post
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!
unfortunately i do not. my life sucks

----------

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;

	while (USD != 0)
	CAD = 0.98 * USD; 
	USD = 0.98 *CAD;

	cout << "$" << CAD << " CAD is equal to $" << USD << " USD" << endl;
		
	return 0;

}
oxshannon is offline   0 Reply With Quote
Old Jan 29, 2012, 07:15 PM   #90
mobilehaathi
macrumors 601
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: The Anthropocene
Quote:
Originally Posted by oxshannon View Post
unfortunately i do not. my life sucks
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?

----------

Quote:
Originally Posted by oxshannon View Post
[/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;

	while (USD != 0)
	CAD = 0.98 * USD; 
	USD = 0.98 *CAD;

	cout << "$" << CAD << " CAD is equal to $" << USD << " USD" << endl;
		
	return 0;

}
You don't need what I've bolded.
__________________
The true way is along a rope that is not spanned high in the air, but only just above the ground. It seems intended more to cause stumbling than to be walked along.
mobilehaathi is offline   0 Reply With Quote
Old Jan 29, 2012, 07:17 PM   #91
oxshannon
Thread Starter
macrumors regular
 
Join Date: Jan 2012
Quote:
Originally Posted by mobilehaathi View Post
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.
oxshannon is offline   0 Reply With Quote
Old Jan 29, 2012, 07:19 PM   #92
mobilehaathi
macrumors 601
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: The Anthropocene
Quote:
Originally Posted by oxshannon View Post
aw yay! thank you so much for your help i cant believe i was being that dumb.
You'll get the hang of it.
__________________
The true way is along a rope that is not spanned high in the air, but only just above the ground. It seems intended more to cause stumbling than to be walked along.
mobilehaathi is offline   0 Reply With Quote
Old Jan 29, 2012, 07:33 PM   #93
oxshannon
Thread Starter
macrumors regular
 
Join Date: Jan 2012
Quote:
Originally Posted by mobilehaathi View Post
You'll get the hang of it.
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

----------

Quote:
Originally Posted by oxshannon View Post
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..
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;
}
yay me?
oxshannon is offline   0 Reply With Quote
Old Jan 29, 2012, 07:36 PM   #94
mobilehaathi
macrumors 601
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: The Anthropocene
Quote:
Originally Posted by oxshannon View Post
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..
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;
}
yay me?
See, you're getting the hang of it!
__________________
The true way is along a rope that is not spanned high in the air, but only just above the ground. It seems intended more to cause stumbling than to be walked along.
mobilehaathi is offline   1 Reply With Quote
Old Jan 29, 2012, 07:49 PM   #95
oxshannon
Thread Starter
macrumors regular
 
Join Date: Jan 2012
yayyyyyy
oxshannon is offline   3 Reply With Quote
Old Jan 29, 2012, 08:13 PM   #96
chrono1081
macrumors 604
 
chrono1081's Avatar
 
Join Date: Jan 2008
Location: Isla Nublar
Programming 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
__________________
Mac Pro (2010): 3.33Ghz Intel Xeon (6 core) - 24 GB RAM - NVidia Quadro k5000
Macbook Air (2010): 2.13 Ghz Intel Core 2 Duo - 4GB RAM
chrono1081 is offline   1 Reply With Quote
Old Jan 30, 2012, 09:49 AM   #97
oxshannon
Thread Starter
macrumors regular
 
Join Date: Jan 2012
Quote:
Originally Posted by chrono1081 View Post
Programming 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
oxshannon is offline   1 Reply With Quote
Old Jan 30, 2012, 09:55 AM   #98
mobilehaathi
macrumors 601
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: The Anthropocene
Quote:
Originally Posted by oxshannon View Post
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
Hehehe, welcome to programming!
__________________
The true way is along a rope that is not spanned high in the air, but only just above the ground. It seems intended more to cause stumbling than to be walked along.
mobilehaathi is offline   1 Reply With Quote
Old Jan 30, 2012, 01:50 PM   #99
danwilliams
macrumors member
 
Join Date: Sep 2008
Quote:
Originally Posted by oxshannon View Post
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
Having been a software developer for the last 20 years, I can safely say that you have just done one of the hardest things in programming. You completed your first few assignments. And (bonus points) you got a rush at that "aha" moment of when it compiled and worked.

One of the comments by you earlier was that you were "not good at algebra". Just realize this is a justification for not trying or giving up. You have just proven to yourself (and us) that you DID NOT GIVE UP. All of us on this thread can attest that we have been in the same exact position you were just in earlier in our careers. We too did not give up. And we too came up with justifications to give up. "It's too hard." "I suck at writing." "I hate math." "I am an artist." "I am a lover not a fighter." "I hate it." etc...

Hang in there. With time and the effort you just showed, it will get easier.
danwilliams is offline   1 Reply With Quote
Old Jan 30, 2012, 03:59 PM   #100
chrono1081
macrumors 604
 
chrono1081's Avatar
 
Join Date: Jan 2008
Location: Isla Nublar
I remember when I was learning my biggest issue was with classes. I was so confused by them! The syntax was weird, I didn't get what purpose they served, and the example I was given was awful.

After some digging I found a tutorial on them that didn't try and impress the reader by showing all kinds of bells and whistles but instead showed a basic class, then it clicked and now I can't imagine never creating classes.

You will run in to many scenarios like that in programming but with a bit of digging you'll find examples that work for you and whatever you are trying to understand will click and you'll be on your way to the next concept.
__________________
Mac Pro (2010): 3.33Ghz Intel Xeon (6 core) - 24 GB RAM - NVidia Quadro k5000
Macbook Air (2010): 2.13 Ghz Intel Core 2 Duo - 4GB RAM
chrono1081 is offline   1 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
[mac mini or imac for] xcode grandM iPhone/iPad Programming 27 Mar 7, 2014 11:51 AM
Where is my gcc and g++ compiler sysProgrammer Mac Programming 10 Nov 24, 2013 06:47 PM
Moving from xcode 3.2 to xcode 4.5.2 compilation error for 'abs' macro in stdlib.h hrishidev Mac Programming 7 Jun 2, 2013 10:36 AM
Broken C compiler dancks Mac Programming 2 Jun 15, 2012 03:04 PM
xcode on mac mini erfg12 iPhone/iPad Programming 4 Jun 12, 2012 10:07 AM

Forum Jump

All times are GMT -5. The time now is 12:18 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC