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
Christopher
NA
7
0
insertting values into an arrays elements
Jun 25 2010 2:30 PM
Hi all,
I'm having trouble figuring out why the values the user inputs aren't being inserted into the proper element in the range array. Can someone shed some light on this? I'm a noob.
Thanks!
static void Main(string[] args)
{
int m0 = 1;
int m1 = 1;
int m2 = 1;
int m3 = 1;
int m4 = 1;
int m5 = 1;
int m6 = 1;
int m7 = 1;
int m8 = 1;
int m9 = 1;
Console.WriteLine("How many entries today?");
int entries = Convert.ToInt32(Console.ReadLine());
int[] array = new int[entries];
int[] range = new int[9];
foreach (int i in array)
{
Console.WriteLine("Enter your sales amount");
int sales = Convert.ToInt32(Console.ReadLine());
if (sales >= 200 && sales <= 299)
{
range[0] = m0++;
}
if (sales >= 300 && sales <= 399)
{
range[1] = m1++;
}
if (sales >= 400 && sales <= 499)
{
range[2] = m2++;
}
if (sales >= 500 && sales <= 599)
{
range[3] = m3++;
}
if (sales >= 600 && sales <= 699)
{
range[4] = m4++;
}
if (sales >= 700 && sales <= 799)
{
range[5] = m5++;
}
if (sales >= 800 && sales <= 899)
{
range[6] = m6++;
}
if (sales >= 900 && sales <= 999)
{
range[7] = m7++;
}
if (sales >= 1000 && sales <= 9999)
{
range[8] = m8++;
}
}
foreach (int i in range)
{
Console.WriteLine(range[i]);
}
Console.Read();
}
Reply
Answers (
2
)
Windows Form App - Business Days/Hours
DIP + AI on c# -> plz help