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
herbie
NA
14
0
new to arrays
Apr 13 2007 11:08 AM
I am
learning
arrays and have a program that needs some help. What I am trying to do is enter the miles of a trip then get a ticket price. For example 0-99 miles would be $25, 100-299...$40,...300-499,...$55 farther than 500 miles is $70. Here is what I have any pointers would be appericated. I know I need to account for all the miles 0-500 Thanks
using System;
public class Miles
{
public static string GetMiles()
{
string Miles;
Console.WriteLine("Enter miles ");
Miles = Console.ReadLine();
return Miles;
}
public static void Main()
{
string Miles;
Miles = GetMiles();
int[] distanceMiles = {0, 100, 300, 500};
double[] price = {25.00, 40.00, 55.00, 70.00};
double customerMiles;
int sub = 4;
while(sub >= 0 && Convert.ToInt32(Miles) < distanceMiles[sub])--sub;
customerMiles = price[sub];
}
}
Reply
Answers (
3
)
Sage line 50 v 11 and VB.NET connection
purpose of this code