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
Maha
NA
0
326.4k
What’s wrong with this program?
Oct 3 2012 2:01 PM
This program is producing correct output for "
Belt
" and "
Tie
" input. But for the other inputs ("
Scarf
" and "
Cufflinks
") program output is "No match found". Anyone can fix the error.
// Debug06-01
// Lists items for sale and their prices
using System;
public class DebugSix01
{
public static void Main()
{
string[] items = { "Belt", "Tie", "Scarf", "Cufflinks"};
double[] prices = { 29.00, 35.95, 18.50, 112.99 };
Console.Write("Items for sale: ");
string enterItem = Console.ReadLine();
int arrayPosition = Array.BinarySearch(items, enterItem);
if (arrayPosition < 0)
Console.WriteLine("No match found");
else
Console.WriteLine("Price {0}", prices[arrayPosition].ToString("c"));
Console.ReadKey();
}
}
Reply
Answers (
2
)
Turn an integer into a month name
Windows Forms app with no forms shown