A List of some of the Best Paying Cities for Technology Jobs: Cities Annual Medi
ID: 3781896 • Letter: A
Question
A List of some of the Best Paying Cities for Technology Jobs:
Cities
Annual Median Wage
Santa Fe, New Mexico
$100,050
Bethesda, Maryland
$96,020
Anniston, Alabama
$89,740
Durham, North Carolina
$84,910
Lawrence and Salem, Massachusetts
$80,840
Write a program which asks a user to enter their current salary and select from one of the following cities. Based on the input and selection, calculate and display whether or not the user is earning above or below the annual median wage of the selected city. Also display the different between the user’s salary verses the location’s annual median wage. If the user enters an option that is not in the above table, the program should display “Invalid Option Selected”. You must use nested if-else statements and string type to solve this problem.
The following is a sample output:
Please Enter your current Salary: 80000
Option 1: Santa Fe, New Mexico
Option 2: Bethesda, Maryland
Option 3: Anniston, Alabama
Option 4: Durham, North Carolina
Option 5: Lawrence and Salem, Massachusetts
Please Select a City from the Above list (Option 1 – 5): 2
You have entered a salary of $80000 and selected option: 2 for the city.
The Median Salary for This City is $96020. You are currently earning $16020 below the Median Salary.
Press any key to continue…
Cities
Annual Median Wage
Santa Fe, New Mexico
$100,050
Bethesda, Maryland
$96,020
Anniston, Alabama
$89,740
Durham, North Carolina
$84,910
Lawrence and Salem, Massachusetts
$80,840
Explanation / Answer
#include <iostream>
using namespace std;
int main() {
int csalary;
char city;
int S=100050;
int B=96020;
int A=89740;
int D=84910;
int L=80840;
cout<<"Please Enter your current Salary:";
cin>>csalary;
//taken intial of each city to allot values
cout<<"Option 1: Santa Fe, New Mexico"<< endl;
cout<<"Option 2: Bethesda, Maryland"<< endl;
cout<<"Option 3: Anniston, Alabama"<< endl;
cout<<"Option 4: Durham, North Carolina"<< endl;
cout<<"Option 5: Lawrence and Salem, Massachusetts"<< endl;
cout<<"Please Select a City from the Above list (Option 1 – 5):";
cin>>city;
cout<<endl<<endl;
switch(city) {
case '1' :
cout << "You have entered a salary of";
cout<<csalary;
cout<< " and selected option: 1 for the city."<< endl << endl;
if(csalary<S){
int res=S-csalary;
cout<<"The Median Salary for This City is";cout<< S;cout<< ". You are currently earning $";
cout<< res;cout<< " below the Median Salary."<<endl;
cout<<"Press any key to continue…";
} else{
int res=csalary-S;
cout<<"The Median Salary for This City is";cout<< S;cout<< ". You are currently earning $";
cout<< res;cout<< " above the Median Salary."<<endl;
cout<<"Press any key to continue…";
}
break;
case '2' :
cout << "You have entered a salary of";cout<<csalary;cout<< " and selected option: 2 for the city."<< endl << endl;
if(csalary<B){
int res=B-csalary;
cout<<"The Median Salary for This City is";cout<< B;cout<< ". You are currently earning $";
cout<< res;cout<< " below the Median Salary."<<endl;
cout<<"Press any key to continue…";
} else{
int res=csalary-B;
cout<<"The Median Salary for This City is";cout<< B;cout<< ". You are currently earning $";
cout<< res;cout<< " above the Median Salary."<<endl;
cout<<"Press any key to continue…";
}
break;break;break;
case '3' :
cout << "You have entered a salary of";cout<< csalary;cout<< " and selected option: 3 for the city." << endl << endl;
if(csalary<A){
int res=A-csalary;
cout<<"The Median Salary for This City is";cout<< A;cout<< ". You are currently earning $";
cout<< res;cout<< " below the Median Salary."<<endl;
cout<<"Press any key to continue…";
} else{
int res=csalary-A;
cout<<"The Median Salary for This City is";cout<< A;cout<< ". You are currently earning $";
cout<< res;cout<< " above the Median Salary."<<endl;
cout<<"Press any key to continue…";
}
break;
case '4' :
cout << "You have entered a salary of";cout<< csalary;cout<< " and selected option: 4 for the city." << endl << endl;
if(csalary<D){
int res=D-csalary;
cout<<"The Median Salary for This City is";cout<< D;cout<< ". You are currently earning $";
cout<< res;cout<< " below the Median Salary."<<endl;
cout<<"Press any key to continue…";
} else{
int res=csalary-D;
cout<<"The Median Salary for This City is";cout<< D;cout<< ". You are currently earning $";
cout<< res;cout<< " above the Median Salary."<<endl;
cout<<"Press any key to continue…";
} break;
case '5' :
cout << "You have entered a salary of";cout<< csalary;cout<< " and selected option: 5 for the city." << endl << endl;
if(csalary<L){
int res=L-csalary;
cout<<"The Median Salary for This City is";cout<< L;cout<< ". You are currently earning $";
cout<< res;cout<< " below the Median Salary."<<endl;
cout<<"Press any key to continue…";
} else{
int res=csalary-L;
cout<<"The Median Salary for This City is";cout<< L;cout<< ". You are currently earning $";
cout<< res;cout<< " above the Median Salary."<<endl;
cout<<"Press any key to continue…";
}break;
default :
cout << "Invalid Option Selected" << endl;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.