can someone help me with this question in c++ please Benefits Type Price Gold $5
ID: 3933865 • Letter: C
Question
can someone help me with this question in c++ please
Explanation / Answer
Code:
#include <iostream>
#include <string>
using namespace std;
int main() {
string fname,lname,addr,email,type;
int byear,mtype,cyear = 2016,age,price;
cout << "Enter your first name: ";
cin >> fname;
cout << "Enter your last name: ";
cin >> lname;
cout << "Enter your address: ";
cin >> addr;
cout << "Enter your email: ";
cin >> email;
cout << "Enter your birth year: ";
cin >> byear;
cout << "Enter 1 for Gold or 2 for Platinum: ";
cin >> mtype;
age = cyear - byear;
if(mtype == 1){
price = 55 * age;
type = "Gold card";
}else if(mtype == 2){
price = 110 * age;
type = "Platinum card";
}else{
cout << "Enter either 1 or 2" << endl;
}
cout << lname << " " << fname << " " << age << endl;
cout << addr << " " << email << endl;
cout << type << " :$" << price << endl;
}
Output:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.