-4
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main() {

    string gun = "";
    cout << "Enter The Gun You Would Like To Know The Type Of Ammo For: \n";
    getline(cin, gun);
    if (gun == "b95" || "B95" || "windchester" || "wind chester" || "Windchester" || "Wind Chester" || "longhorn" || "Long Horn" || "fal" || "FAL")
    {
        cout << "The Type Of Ammo For The " << gun << " Is 308 Windchester";
    }   
    if (gun == "izh rifle" || "IZH Rifle" || "izhrifle" || "izh rifle" || "sks" || "SKS" || "akm" || "AKM")
    {
        cout << "The Type Of Ammo For The " << gun << " 7.62x39mm";
    }
    if (gun == "Mangnum" || "mangnum" || "Repetor" || "repetor")
    {
        cout << "The Type Of Ammo For The " << gun << ".357";
    }
    return 0;
}

When the program is run for example i would enter sks and it would output all of the cout messages for example: The Type Of Ammo For The sks Is 308 WindchesterThe Type Of Ammo For The sks 7.62x39mmThe Type Of Ammo For The sks.357

Anju
  • 631
  • 2
  • 9
  • 25
  • 3
    Your if conditions do not do what you want them to do. Please [read a good book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) and learn C++ from it instead of guessing. – Rakete1111 Jun 05 '17 at 07:21

2 Answers2

0

If conditions does not work this way. If you want this, you have to write it like:

 if (gun == "izh rifle" || gun ==  "IZH Rifle" || gun == "izhrifle" || gun ==  "izh rifle" || 
   gun ==  "sks" ||gun ==  "SKS" ||gun ==  "akm" ||gun ==  "AKM")

Basically proper comparison requires two values to be compared, not just one.

0

You can't write boolean expressions like this in C++. Every side of boolean expression is a boolean, so in your case all three if are always true because non-empty string is a true in boolean expression. Please read about boolean expressions and write smthing like If (input == "str1" || input == "str2" etc. )

tty6
  • 1,203
  • 11
  • 30