You can cook spaghetti in a microwave.
Simply place the spaghetti in a microwave safe bowl and add water to cover the spaghetti.
Then cook the spaghetti in the microwave on high for around 15 minutes and check it after every 5 minutes or so.
You may need to stir the spaghetti during the time you microwave it.
While spaghetti and pasta cook better on the stove in a pot of boiling water the microwave can also be used to cook spaghetti and pasta.
Boiling pasta in the microwave saves a ton of time and tastes (basically) the same.
Just put the pasta in a microwaveable bowl, fill it with water until all the pasta is covered (break if necessary) and microwave for 10 to 15 minutes depending on how much spaghetti or pasta you're cooking, uncovered (or 3 more minutes than recommended on the box).
When I had no stove I used to cook spaghetti and pasta in the microwave all the time and it worked just fine.
Food with a high water content that is cooked in a microwave tastes just like it has been boiled, but if you microwave food with a lower water content, the little moisture it originally had gets steamed out of it, leaving the food unpalatably dry and brittle.