The program I'm trying to code needs to consist of the following:
Letting a user input the name and prices for 10 stocks and store the names and values of these stocks into two separate arrays. From there, you will ask the user (using a menu) to make a selection:
1. Convert from dollars to pounds.
2. Convert from dollars to euros.
3. Average the prices of the 10 stocks.
4. Count up how many stocks are above $25.
5. Display the stocks sorted.
Write "IF statements that will handle the above menu and do the selected choice." Use the following guidelines:
1. $1 US dollar is 0.97 pounds.
2. $1 in US is 0.45 euros.
3. Do the average of all 10 stocks.
4. You will use an "IF Statement" to see if the price is above 25 for each value in the array.
5. Use only the "Bubble Sort algorithm" to display the stocks sorted.
I need to have the output for whichever selection the user selects, and from there I will then need to look through the program.
**NOTE** MUST use a "Switch Statement" when looking through to see what selection was made.
Here is the code I have written. Please go easy on me for I am very new to the any kind of coding and programming language. I just don't understand 90% of any of this. Please try to help me code and explain in the simplest terms possible.
I have honestly tried and tried to get to this work after many hours. I not having much luck at all with this. Here is the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include <iostream>
using namespace std;
#include <math.h>
#include <string>
void main(){
int selection;
double prices[10];
string names[10];
int i;
char wait='a';
do{
cout << "Please make your selection: " << endl;
cout << "What would you like to do: " << endl;
cout << "--------------------------" << endl;
cout << "1. Convert from Dollars to Pounds.\n2. Convert from Dollars to Euros.";
cout << endl;
cout << "3. Average the prices of the 10 stocks. ";
cout << endl;
cout << "4. Count up how many stocks are above $25. ";
cout << endl;
cout << "5. Display the stocks sorted. ";
cout << endl << endl;
cin >> selection ;
cout << endl << endl;
for(int i=1; i<=9; i++){
cout << "\nEnter a stock name: ";
cin >> selection;
cout << "\nEnter a stock price: ";
cin >> selection;
}
switch (selection){
case 1:
prices[10] =(prices[10]*0.97);
cout<<"\n1. Convert from Dollars to Pounds.\n2. Convert from Dollars to Euros. " << prices;
break;
case 2:
prices[10] =(prices[10]*0.45);
cout<<"\n2. Convert from Dollars to Euros." << prices;
break;
case 3:
prices[10] = (prices[10] + prices[10]) / 10.0;
cout<<"\n3. Average prices of 10 stocks. " << prices;
break;
case 4:
prices[10] = prices[10] < 25.00;
cout << "\n4. Count stocks that are above $25. " << prices;
break;
}
cout << "Enter 1 to continue, any other key to exit:" ;
cin >> wait;
}while(wait != 'x' && wait != 'X');
return;
}
| |