Am I typing std::cin correctly? https://www.codecademy.com/workspaces/626b8c685fc8977efa5dfad3

Hello.
I made a program in a workspace and std::cin is not working, a tried it in another program and it still did not work.
I reported this problem five days ago but got no solution.
Can someone please tell me what is wrong so that I can fix this problem.

Here’s the link:

https://www.codecademy.com/workspaces/626b8c685fc8977efa5dfad3

Here’s the code:

#include<iostream>
#include<vector>

std::vector<int>Numbers;
int storage = 0;
int storage2 = storage ;


int main() {

std::cout <<"Welcome to the even and odd numbers calculator\n";
std::cout <<"Please enter first number (single digit only)\n";
std::cin >> storage  ;
Numbers.push_back(storage2);


std::cout <<"Next number please\n";
std::cin >> storage ;
Numbers.push_back(storage2);


std::cout <<"And anoter one\n";
std::cin >> storage ;
Numbers.push_back(storage2);


std::cout <<"Anoter one\n";
std::cin >> storage ;
Numbers.push_back(storage2);


std::cout <<"And anoter one\n";
std::cin >> storage ;
Numbers.push_back(storage2);


std::cout <<"Thank you, Here is your anser.\n";

double even = 0;
double odd = 0;

for (int i = 0; i < Numbers.size(); i++)  {

  if (Numbers[i] == 1) {
odd = odd + Numbers[i];
  }
 else if (Numbers[i] == 2) {
    even = even + Numbers[i];
  }
  else if (Numbers[i] == 3) {
    odd = odd + Numbers[i];
  }
   else if (Numbers[i] == 4) {
    even = even + Numbers[i];
  }
   else if (Numbers[i] == 5) {
    odd = odd + Numbers[i];
  }
   else if (Numbers[i] == 6) {
    even = even + Numbers[i];
  }
   else if (Numbers[i] == 7) {
    odd = odd + Numbers[i];
  }
   else if (Numbers[i] == 8) {
    even = even + Numbers[i];
  }
   else if (Numbers[i] == 9) {
    odd = odd + Numbers[i];
  }

}



std::cout <<"Sum of Even numbers\n";
std::cout << even<<"\n";

std::cout <<"Sum of Odd numbers\n";
std::cout << odd<<"\n";

std::cout <<"Thankyou for using the Even and Odd Numbers Calculator\n";
















}

Here’s a screenshot of the error:

Thanks for the help and support. :+1:

Hey!

Some Codecademy environments, it seems including that one, just aren’t built to take in user input unfortunately, so tools like cin wouldn’t work. I’d suggest using something like Replit online or Visual Studio locally if you need to get input from the user instead :slightly_smiling_face:

Happy coding!

Thankyou so much!
Have a nice day. :wink:

1 Like