No matter what letter I input, it gives me the first option, I’m looking for the error but I’m new, 3 days learning so far, so I honestly don’t see it and I don’t know what I’m doing wrong.
In case anyone wants to know what course I’m doing it’s this one.
Here is the code that has the problem:
#include <iostream>
#include <string>
using namespace std;
struct Pack {
double Price;
char Package;
};
int main() {
Pack Basic;
Basic.Price = 29.99;
Basic.Package = 'A';
Pack Essential;
Essential.Price = 39.99;
Essential.Package = 'B';
Pack Premium;
Premium.Price = 49.99;
Premium.Package = 'C';
Pack Advance;
Advance.Price = 89.99;
Advance.Package = 'D';
Pack Ultimate;
Ultimate.Price = 199.99;
Ultimate.Package = 'E';
Pack PremiumFam;
PremiumFam.Price = 69.99;
PremiumFam.Package = 'F';
Pack AdvanceFam;
AdvanceFam.Price = 89.99;
AdvanceFam.Package = 'G';
Pack UltimateFam;
UltimateFam.Price = 249.99;
UltimateFam.Package = 'H';
cout << "McAfee Package refund % Multiplier" "nn";
cout<< "This program will allow you to get the refund % of any packages" "n" "Please see Packages below: " "nn";
cout<< "A- Basic $29.99" "n" "B- Essential $39.99 " "nn";
cout<< "C- Premium: $49.99" "n" "D- Advance (Individual) $89.99" "n" "E- Ultimate (Individual) $199.99" "nn";
cout<< "F- Premium (Family) $69.99" "n" "G- Advance (Family) $69.99" "n" "H- Ultimate (Family) $249.99" "nn";
char Intro;
cout<< "Please select the package by letter assigned: " "n";
cin>> Intro;
if (Intro = Basic.Package) {
cout<< "The Package selected is: " << "Basic" << "t" << "At a cost of: $" << Basic.Price;
} else if (Intro = Essential.Package) {
cout<< "The Package selected is: " << "Essential" << "t" << "At a cost of: $" << Essential.Price;
} else if (Intro = Premium.Package) {
cout<< "The Package selected is: " << "Premium" << "t" << "At a cost of: $" << Premium.Price;
} else if (Intro = Advance.Package) {
cout<< "The Package selected is: " << "Advance (Individual)" << "t" << "At a cost of: $" << Advance.Price;
} else if (Intro = Ultimate.Package) {
cout<< "The Package selected is: " << "Ultimate (Individual)" << "t" << "At a cost of: $" << Ultimate.Price;
} else if (Intro = PremiumFam.Package) {
cout<< "The Package selected is: " << "Premium (Family)" << "t" << "At a cost of: $" << PremiumFam.Price;
} else if (Intro = AdvanceFam.Package) {
cout<< "The Package selected is: " << "Advance (Family)" << "t" << "At a cost of: $" << AdvanceFam.Price;
} else {
cout<< "The Package selected is: " << "Ultimate (Family)" << "t" << "At a cost of: $" << UltimateFam.Price;
}
return 0; }
Heropig1773 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
5
You have missed a equal to symbol
if (Intro == Basic.Package) {
cout<< "The Package selected is: " << "Basic" << "t" << "At a cost of: $" << Basic.Price;
} else if (Intro == Essential.Package) {
cout<< "The Package selected is: " << "Essential" << "t" << "At a cost of: $" << Essential.Price;
} else if (Intro == Premium.Package) {
cout<< "The Package selected is: " << "Premium" << "t" << "At a cost of: $" << Premium.Price;
} else if (Intro == Advance.Package) {
cout<< "The Package selected is: " << "Advance (Individual)" << "t" << "At a cost of: $" << Advance.Price;
} else if (Intro == Ultimate.Package) {
cout<< "The Package selected is: " << "Ultimate (Individual)" << "t" << "At a cost of: $" << Ultimate.Price;
} else if (Intro == PremiumFam.Package) {
cout<< "The Package selected is: " << "Premium (Family)" << "t" << "At a cost of: $" << PremiumFam.Price;
} else if (Intro == AdvanceFam.Package) {
cout<< "The Package selected is: " << "Advance (Family)" << "t" << "At a cost of: $" << AdvanceFam.Price;
} else {
cout<< "The Package selected is: " << "Ultimate (Family)" << "t" << "At a cost of: $" << UltimateFam.Price;
}
Intro == Basic.Package this is the part you have missed
if you gave it like Intro = Basic.package it assigns the Intro as Basic.package value which it contains Thats the issue you got same error
Varun is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.