TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prime b
NA
810
346.8k
Array problem
Jan 6 2012 1:42 PM
This is my problem
Write a program for a package delivery service. Th e program
contains an array that holds the ten zip codes to which the
company delivers packages. Prompt a user to enter a zip
code and display a message indicating whether the zip code
is one to which the company delivers
My question is if you run it, then its going to display 9 messages "Sorry we dont deliver package to this location", and 1 message "We deliver shipping to this location". I know its something about my loop but i am not sure what it is
What I have done
int[] zipCode = new int[10] { 28303, 21303, 9103, 6532, 9011, 6534, 8426, 0989, 4735, 8643 };
string inputString;
int validZipCode;
Console.WriteLine("Please enter zipcode");
inputString = Console.ReadLine();
validZipCode = Convert.ToInt32(inputString);
for (int x = 0; x < zipCode.Length; ++x)
{
if (validZipCode == zipCode[x])
{
Console.WriteLine("We deliver shipping to this location");
}
else
Console.WriteLine(" Sorry we dont deliver package to this location");
Reply
Answers (
2
)
How do you pass List
as argument?
Adding to a list