+ 1
How to have multiple possible inputs for a code in C++?
Okay so its kinda hard to explain but I'll try my best. I'm trying to code different possible inputs that have the same result. This is what I have/trying to do : cout<< "(d/D/2) - Double Star Polygon"<<endl; What do I assign d, D, and 2 ? Basically if the user inputs d/D/2 it outputs their selection as well as the "Double Star Polygon" and if the user inputs anything different it states that their input is invalid. Hopefully one of you can help.
7 Answers
+ 2
Can you show your code?
+ 1
yea, i'm trying to calculate different types of stars based on what the user inputs, this is what i have so far:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;
int main(){
double length_Long = 0;
const double PI = 3.141592653589793;
double length_Short = 0;
double height = 0;
double height_Long = 0;
double height_Short = 0;
double base = 0;
double length = 0;
double diameter = 0;
double perimeter = 0;
double area = 0;
double base_Length = 0;
double perimeter_Length = 0;
double edge_Length = 0;
double inner_Angle = 0;
double outer_Angle = 0;
double spike_Base = 0;
double spike_Height = 0;
double chord_Length = 0;
double number_of_Points = 0;
cout<<"*******************************************"<<endl;
cout<< "* Rebel Alliance Computation Support"<<endl;
cout<< "* Star area calculator"<<endl;
cout<< "*******************************************"<<endl;
cout<< " "<<endl;
cout<< "(d/D/2) - Double Star Polygon"<<endl;
cout<< "(t/T/3) - Three Star Polygon"<<endl;
cout<< "(p/P) - Polygram Polygon"<<endl;
cout<< "(q/Q) - Quit"<<endl;
0
I applied that to the first part of the code:
if(user_Input == 'd' || user_Input == 'D' || user_Input == '2')
{
cout<<"Your selection: "<<user_Input<<endl;
cout<<"Double Star Polygon Calculator"<<endl;
}
and when i run the program and input any of the three possible inputs it just says press any key to continue. why isn't it displaying what its suppose to do?
0
yea my bad, here is the link, hopefully it works https://code.sololearn.com/cyJ0IjKJHewZ