Write a program to input the user\'s 5-digit ZIP code, and output which city the
ID: 3671339 • Letter: W
Question
Write a program to input the user's 5-digit ZIP code, and output which city they live in from the following table. Use a switch statement to do it.
Using C++ on macbook, so if you can use that, it would be great. thanks
First three digits of ZIP code City
1. 900 or 901 Los Angeles (and area)
2. 921 San Diego (and area)
3. 937 Fresno (and area)
4. 941 San Francisco
5. 942 Sacramento
6. 946 Oakland (and area)
****can you please use C++, and not write this on paper. i posted this question earlier and i couldn't understand the handwriting that was writen on a piece of paper that was submitted. Also if you can provide a sample screenshot that would be great***
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
int zip,first3;
cout<<"Enter 5 digit zip code::";
cin>>zip;
first3 = zip/100;
switch(first3)
{
case 900:
case 901:
cout<<"Los Angeles (and area) ";
break;
case 921:
cout<<"San Diego ";
break;
case 937:
cout<<"Fresno (and area) ";
break;
case 941:
cout<<"San Francisco ";
break;
case 942:
cout<<"Sacramento ";
break;
case 946:
cout<<"Oakland (and area) ";
break;
default:
cout<<"I dont know!!! ";
}
return 1;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.