Answer:
The function is as follows:
void readAndConvert(){
int n; string symbol,name;
cin>>n;
cin>>symbol;
cin.ignore();
getline (cin,name);
vector<string> trades;
string trade;
for (int inps = 0; inps < n; inps++){
getline (cin,trade);
trades.push_back(trade);}
cout<<name<<" ("<<symbol<<")"<<endl;
for (int itr = 0; itr < n; itr++){
string splittrade[3]; int k = 0;
for(int j=0;j<trades.at(itr).length();j++){
splittrade[k] += trades.at(itr)[j];
if(trades.at(itr)[j] == ' '){
k++; }}
cout<<splittrade[2]<<": "<<floor(stod(splittrade[1]) * stod(splittrade[0]))<<endl; }
}
Explanation:
See attachment for complete program where comments are used to explain each line
When working with a large worksheet, you can split the window into two or four panes.
You're setting the value of user_num to 20. Doing this won't allow the other test cases to run. Simply delete that line and your code should work. This is the code I wrote:
user_num = int(input())
while user_num>=1:
user_num/=2
print(user_num)
I wrote my code in python 3.8. I hope this helps.