C++ looping and exponents?

Filed Under (Programming & Design) by jepes on 14-02-2012

asking this at February 14, 2012 – 18:55 pm

I am 2 days into C++, and have a question about this program:

#include
#include
#include
using namespace std;

int main()
{
int number;
int number2;
int exponent = 1;
string choice;

cout < < "Would you like to add, div, mult, sub or exponent? " << endl;
cin >> choice;

if (choice == “add”)
{
cout < < "Enter the first digit: "<< endl;
cin >> number;

cout < < "Enter the second digit: " << endl << endl;
cin >> number2;
cout < < "The answer is " << number + number2 << endl;

}
else if (choice == "div")
{
cout << "Enter the first digit: " << endl;
cin >> number;

cout < < "Enter the second digit " << endl << endl;
cin >> number2;
cout < < "The answer is " << number /number2 << " with a remainder of " << number % number2 << endl;
}

else if (choice == "mult")
{
cout << "Enter the first digit: " << endl;
cin >> number;

cout < < "Enter the second digit: " << endl << endl;
cin >> number2;
cout < < "The answer is " << number * number2 << endl;
}

else if (choice == "sub")
{
cout << "Enter the first digit: " << endl;
cin >> number;

cout < < "Enter the second digit: " << endl << endl;
cin >> number2;
cout < < "The answer is " << number + number2 << endl;
}
else if (choice == "exponent")
{
cout << "Enter the base number: " << endl;
cin >> number;

cout < < "Enter the exponent: " << endl << endl;
cin >> number2;

for (int i = 1; i < = number2; i++)
{
exponent = (i * number2);
}
cout << "The answer is " << exponent << endl;
}
else
{
cout << "That answer is not permitted by the program " << endl;
}
return 0;
}

Okay, so it all runs how I want it, except the exponent formula. Can someone explain how to make the exponents work as well as how to loop back to the first question after each little calculation, so they can keep using it? If you need something answered I will be glad to supply in additional info so thanks in advance.
but the only thing the string represents is the first question, then after that the int variables represent all for the numbers?

Chosen Answer:

oops, February 14, 2012 – 19:10 pm (5 Stars)

, which you`ve included, has a function called `pow`, which does exponents. So you can just do this:

cout < < "The answer is " << pow(number, number2) << endl;

For looping back to the top, just surround your code in a while loop, like this:

    while (true)
    {
        cout << "Would you like to add, div, mult, sub or exponent? " << endl;
        cin >> choice;
        …
        …
        …
        else
        {
             cout < < "That answer is not permitted by the program " << endl;
        }
    }

You probably want to give the user an option to end the program though, so you can change your question to "Would you like to add, div, mult, sub, exponent or quit?". And then you can just add another else if condition like this:

    else if (choice == "quit")
    {
        break; // exits the while loop
    }

Read the rest of this entry »

How can i control a microcontroller with my computer?

Filed Under (Other) by jepes on 14-02-2012

cheeeseyfry asking this at February 14, 2012 – 18:52 pm

I want a microcontroller to output electricity based on a command from the computer. What model of microcontroller and how would i go about accomplishing this?
I live in Pennsylvania and it`s for spinning a motor. Nice try though.

Chosen Answer:

Jonathan, February 14, 2012 – 19:14 pm (5 Stars)

Normally, one would use “h-bridges” to control a DC motor. You don`t say what type of motor you are using though. There is a book called “Intermediate Robot Building,” by David Cook, which is a pretty good beginning tutorial on all things related to driving motors from microcontrollers and testing the circuits. If you can get a copy cheaply, I`d say do it and read. It`s very detailed, doesn`t talk down to you, but does get all the necessary points across, I think. You should like it.

Read the rest of this entry »

On a scale of 1/5, what would you rate this computer as?

Filed Under (Hardware) by jepes on 14-02-2012

asking this at February 14, 2012 – 18:33 pm

• Genuine Windows 7 Home Premium [64-bit]
• Intel(R) Core(TM) i5-2500 quad-core processor [3.3GHz, 6MB cache]
• 8GB DDR3-1333MHz SDRAM [2 DIMMs]
• 1TB 7200 rpm SATA hard drive
• 2GB DDR3 NVIDIA GeForce GT 530 [DVI, HDMI, VGA adapter]
• 20 inch LED monitor

Note that all I ever do is surf the web, edit documents, watch videos and play some light Minecraft.

Chosen Answer:

Anzu, February 14, 2012 – 19:23 pm (5 Stars)

4/5.

OS is fine.
Great processor, even if it isn`t the overclockable one.
RAM is fine.
HDD is fine.
Graphics card is a crappy placeholder graphics card, like the ones you replace with a better one if you choose the retail route. Don`t expect too much from it. It is however fine for your purposes though.
Monitor is fine.

Read the rest of this entry »

video editting help with youtube 10 points best answer?

Filed Under (General) by jepes on 14-02-2012

asking this at February 14, 2012 – 18:08 pm

i made a video on sony vegas and i go to upload it to youtube but it says im not able to upload it cause of the file type. so how do i change the file type on sony vegas 11 pro so its eligable to go on youtube? 10 points for best answer

Chosen Answer:

Max Will, February 14, 2012 – 18:20 pm (5 Stars)

For Sony Vegas 11, there are two ways you can upload the video to youtube.

1. Click File, then `Upload to youtube`. Simply type in your username and password, then a Title, Description, etc. Once done, the `upload` button should be available. Simply click it, and it should begin to upload.

2. From what I take from your problem, that step isn`t working. So, the other alternative, is to `render as`. Basically click File, then click Render as.
Scroll down until you get to `Windows Media Video V11 (*.wmv)`
Click it.
Now, most of these sub-heading should work, but I normally go with `4.8 Mbps HD 720-24p Video`
Click render.
Once done, go to the file you saved it in. (Documents, by defult).
And, if it is there, and all works fine, upload it to youtube.

Hope this helped

Reference: User of both Sony Vegas 11, and Youtube

Read the rest of this entry »

How much does this computer cost?

Filed Under (Hardware) by jepes on 14-02-2012

asking this at February 14, 2012 – 17:56 pm

i7 2700k (never overclocked, but can easily go till 5 GHz with the dark knight cooler)

Asus p8p67 3.1 pro (high end board that can sli/cf, has Bluetooth, excellent overclocking bios, and other amazing features)

MSI Twin Frozr 2 GTX 470 (overclocked to stock GTX 580 performance and still stays below 60 degrees)

Patriot Viper Xtreme 8GB 2X4GB DDR3 1866MHZ PC3-15000 9-11-9-27

WD Black 640 GB + optional 250GB (or 350gb, i forget) Seagate

750W Cooler Master GX Bronze PLUS psu (with a max power output of 900w)

Zalman Z9 PLUS case with an inbuilt temperature sensor in the front.

Creative SounderBlaster Audigy (has EAX support; adds clarity to sound and creates a vivid 7.1 channel experience)

Zigmatech Dark Knight cooler

Wifi N

Genuine Windows 7 Home Premium (can upgrade to Ultimate for a fraction of the cost)

Office 2010

Thanks.

Chosen Answer:

Broodyr, February 14, 2012 – 18:01 pm (5 Stars)

It would be worth $1500 new, but if it`s used, then as MaX said, around $1300.

Read the rest of this entry »

What is the name of this rage face?

Filed Under (General) by jepes on 14-02-2012

asking this at February 14, 2012 – 17:43 pm

I`ve been looking for it, it`s usually the rage face people use when they get spit on their face.

There`s a lot of creases and the eyes are in shock, if anyone knows the name, do tell!
Thanks!
Nope, not me gusta.

It`s like a disgusted/shocked face.

Chosen Answer:

abnm, February 14, 2012 – 17:44 pm (5 Stars)

me gusta?

Read the rest of this entry »

Fibonacci number induction! help please!?

Filed Under (Programming & Design) by jepes on 14-02-2012

asking this at February 14, 2012 – 17:43 pm

please help me with this! i will choose best answer within 10 min of ur answer!
if not the whole thing please help me set the problem up, i can do the n+1 part.

prove that the sum of the first n fibonacci numbers is equal to the (n+2) and fibonacci numbers minus one

Chosen Answer:

Daniel, February 14, 2012 – 18:32 pm (5 Stars)

Let F(N) be the Nth Fibonacci number, and S(N) be the sum of the first N Fibonacci numbers.
The sequence is 1, 1, 2, 3…

For the base case, where N = 1, we wish to prove that S(1) = F(3) – 1. S(1) is 1, and F(3) is 2 from looking at the list above. 1 = 2 – 1, so the base case is proven.

For the inductive case, assume S(N) = F(N+2) – 1. Can we prove that S(N+1) = F(N+3) – 1 from that?
We can add F(N+1) to both sides of the equation. By the definition of S(N), S(N) + F(N+1) = S(N+1). By the definition of F(N), F(N+1) + F(N+2) = F(N+3), so F(N+2) – 1 + F(N+1) = F(N+3) – 1.

Read the rest of this entry »

12 TYPES OF PEOPLE ON FACEBOOK?

Filed Under (General) by jepes on 14-02-2012

asking this at February 14, 2012 – 17:38 pm

12 TYPES OF PEOPLE ON FACEBOOK?
12 TYPES OF PEOPLE ON FACEBOOK.

Who Are You ?? :P

1• The “Rooster” – Feels that it is their job to tell Facebook “Good Morning” every day.

2• The “Lurker” – Never posts or comments on your post, but reads everything, and might make reference to your status if they… see you in public.

3• The “Hyena” – Doesn`t ever really say anything, just LOLs and LMAOs at everything.

4• “Mr/Ms Popular” – Has 4,367 friends f…or NO reason.

5• The “Gamer” – Plays Words With Friends, Mafia Wars, Bakes virtual cakes and stuff, etc., ALL DAY.)

6• The “Cynic” – Hates their life, and everything in it, as evidenced by the somber tone in ALL of their status updates.

7• The “Collector” – Never posts anything either, but joins every group and becomes fans of the most random stuff.

8• The “Promoter” – Always sends event invitations to things that you ultimately delete or ignore.

9• The “Liker” – Never actually says anything, but always clicks the “like” button

10• “Drama Queen/ King” – This person always posts stuff like “I can`t believe this!”, or “They gonna make me snap today!”, in the hopes that you will ask what happened, or what`s wrong…but then they never finish telling the story.

11• The “News” – Always updates you on what they are doing and who they are doing it with, no matter how arbitrary, and lastly….

12• The “Thief” – Steals status updates and wall posts… and will probably steal this one too….JK :-) :-P !!!

WHICH ONE IS YOU… ? ??

Immma thief….considering I stole this XD

Chosen Answer:

Texas Rattlesnake, February 14, 2012 – 17:40 pm (5 Stars)

I have a rooster on my fb and I hate it.

Read the rest of this entry »

macbook pro problems..?

Filed Under (Hardware) by jepes on 14-02-2012

asking this at February 14, 2012 – 17:30 pm

whenever i swipe back a page the internet completely freezes..
how can i refresh the settings or solves this problem in other ways??

Chosen Answer:

JustDoIt, February 14, 2012 – 17:38 pm (5 Stars)

LOL – when you swipe on your MBP how can internet freeze – otherwise I would not have been able to answer this question. I bet you mean to say your MBP browser freezes. I never had that problem and not sure which browser you are using? Safari or Firefox or Chrome. Try other browsers and see if that solves the problem. If it did solve, then one of setting on your browser is messing up with OS level settings.
Not sure if you have upgraded the newer version of Safari ( i think 5.2?) which came out with 10.7.3 update.

Read the rest of this entry »

Which laptop is better (comparison)?

Filed Under (Hardware) by jepes on 14-02-2012

asking this at February 14, 2012 – 17:26 pm

DELL N4030 vs. ASUS A52F-XE4

They are both priced at $340.00

or is there another laptop under $400 that is better than the two?

Chosen Answer:

Glargynarg101359, February 14, 2012 – 17:41 pm (5 Stars)

They are both extremely similar. Their hardware components are identical (the P6200 2.13 GHz processor, RAM amount, and HDD size). The Asus is probably going to be less cheaply-made, but I don`t know for one this inexpensive.. The Asus is about 1.6 inches larger screen size. they both have good displays and same no. of USB ports. Trust your gut and go with the one that feels right. If you want a much more detailed review of the two, please visit my site, nicknology.com, and fill out a “Tech question” and I can go more into this.. Hope it helps!

Read the rest of this entry »