Hey guys,
This is my first official post on DaniWeb :)
I am new at programming in C++ using visual studios, and right now I am fooling around with storing user input into Arrays.
I am having a problem with my code, using an array size of 3 to store the users input into the first 2 spots [0 and 1] and then making a calculation in the 3rd spot[2].
Here is my code:
#include <iostream>
using namespace std;
int main() {
double userInput[3]; //array can only hold *3* elements
cout<<"Enter the number of cars you wish to buy: ";
cin>> userInput[0]; // users input stored into array 0
cout<<"Enter the amount of money you wish to spend for one car: ";
cin>> userInput[1];
//the last array will times the number of cars you wish to buy times
//the amount you wish to spend for one car.
//the value will be stored in the last array
userInput[2] = userInput[0] * userInput[1];
cout<< "According to my calculations... If you were to buy "<<userInput[0]<<" cars, for $"<< userInput[1]<<" each, then the total money you will spend will be $" <<userInput[2]<<endl;
return 0;
}
P.S. How can I spread out the last 'cout' of my code onto multiple lines without disturbing the build so that it works!?
Thanks guys and I hope to hear a respond very soon!
- Ben.