Code/meal.csv
dinner,vegetable sushi,6 rolls,$3.50
dinner,tuna roll,3 rolls,$4.50
dinner,roe, 2 rolls,$3.95
lunch,bento box a - chicken teriyaki,box combo,$8.59
using System;
namespace FileIOManager
{
static class FileLocation
{
public const string INPUT_FILE = "../../Data/meals.csv";
}
}
using System;
using System.IO;
namespace FileIOManager
{
static public class FileReader
{
private static int GetLineCount()
{
StreamReader sr = new StreamReader(FileLocation.INPUT_FILE);
int counter = 0;
while (!sr.EndOfStream)
{
counter++;
sr.ReadLine();
}
sr.Close();
return counter;
}
public static string[] ReadLines()
{
int totalItems = GetLineCount();
string[] itemDetails = new
string[totalItems];
StreamReader sr = new StreamReader(FileLocation.INPUT_FILE);
string itemDetail;
int counter = 0;
while
(!sr.EndOfStream){
itemDetail = sr.ReadLine();
if
(itemDetail.Trim() != "")
itemDetails[counter++] =
itemDetail;
}
sr.Close();
return
itemDetails;
}
}

Bryian TanRank #396 · 6.3K reputationPosted Sep 22, 2010, 7:40 PM EDT
to display the output, replace these lines
David Chen60 reputationPosted Sep 22, 2010, 8:26 PM EDT
the price actually needed to times by 1.8 so Price = Cost * 1.8
also i'll be dealing with bubble sort.. which I have never learn to knew how to coz we have ot make it look like this in the end
* Lunch Items *
$15.46 bento box a - chicken teriyaki, box combo
$17.26 bento box b – sashimi, box combo
* Dinner Items *
$7.11 roe, 2 rolls
$8.10 tuna roll, 3 rolls
$6.30 vegetable sushi, 6 rollsThanks again for your time off
David
David Chen60 reputationPosted Sep 23, 2010, 8:47 PM EDT
string[] meals = System.IO.File.ReadAllLines("meals.csv"); while I created a separate class file like this, but im stuck, dont know how to go any where now. Btw, do you have msn Bryian class MealContent { public string MealTime; public string Entre; public string UnitOfIssue; public double Price = 0.0d; public MealContent(string csvData) { string[] parts = csvData.Split(','); MealTime = parts[0]; Entre = parts[1]; UnitOfIssue = parts[2]; parts[3] = parts[3].Replace('$', ' ').Trim(); Price = double.Parse(parts[3]); } }David Chen60 reputationPosted Sep 22, 2010, 7:42 PM EDT
Bryian TanRank #396 · 6.3K reputationPosted Sep 22, 2010, 8:15 PM EDT
Bryian TanRank #396 · 6.3K reputationPosted Sep 23, 2010, 7:44 PM EDT
What you have so far? Show me your codes.