I don't know what is wrong, Pls help

Hi, I am trying to create a program on the C++ course in the conditionals-logic review.
I am struggling to compile the program because I made a switch statement and it’s telling me that a closing bracket (for the condition) is the problem, but I am supposed to add a closing bracket.

Here’s the link:
https://www.codecademy.com/courses/learn-c-plus-plus/lessons/cpp-conditionals-and-logic/exercises/review

Thanks for your help and support :slight_smile:

Here’s the code:

#include <iostream>

int main() {

double Planet;

double Number;

double Weight;

std::cout << "Enter Destination (Planet Number):\n";

std::cin >> Planet;

 switch (Number) {

  

   case 10:

   std::cout <<"Enter Planet Name\n";

   std::cin >> Planet;

   Weight = 40;

   break;

    case 20:

   std::cout <<"Enter Planet Name\n";

   std::cin >> Planet;

   Weight = 20;

   break;

    case 30:

   std::cout <<"Enter Planet Name\n";

   std::cin >> Planet;

   Weight = 52;

   break;

    case 40:

   std::cout <<"Enter Planet Name\n";

   std::cin >> Planet;

   Weight = 60;

   break;

   default:

   std::cout <<"Enter Planet Name\n";

   std::cin >> Planet;

   Weight = 100;

   break;

 }

It’s not finished yet I just tested it to make sure I am on the right track.

Here’s the terminal output:

$ g++ space.cpp

space.cpp: In function ‘int main()’:
space.cpp:14:16: error: switch quantity not an integer

switch (Number) {
^

Hi,

You never end up closing you int main() bracket I believe!

you have
double Number;
You could change that to
int Number;
so that Number is an integer.

Alternatively,
you could change the cases to doubles/floats:
10.0 instead of 10, and so on.

Ok I will check. :+1:

No it’s not the closing bracket. Thanks for the effort :wink:

Thanks it worked. Have a nice day :+1: