So I been working with visual studio and made the program which calculates the SIR model. Once done, it stores the data into an array and writes its into a CSV file. Got it working, however it is not storing my initial values into the array. Any thoughts why?
Here's is the method which allows the user to set the initial conditions: Sj, Ij, and Rj (These are what I want to be added to the Array)
public double SetInit(double Sj, double Ij, double Rj)
{
Console.WriteLine("The variables Suspected (S), Infected (I), and Recover(R) have already been set to {0}, {1}, and {2} respectively. \n", Sj, Ij, Rj);
{
Console.WriteLine("Would you like to reassign the values?[y][n]");
Console.WriteLine("Please enter either y (for yes) or n (for no)");
ConsoleKey response;
do
{
response = Console.ReadKey(false).Key;
if (response != ConsoleKey.Enter)
Console.WriteLine("\n");
} while (response != ConsoleKey.Y && response != ConsoleKey.N);
if (response == ConsoleKey.N)
{
Console.WriteLine("Okay, the conditions wills remain the same\n");
}
if (response == ConsoleKey.Y)
{
Console.WriteLine("Please a assign a value for S");
String Sinput, Iinput, Rinput = "";
Console.WriteLine("");
Sinput = Console.ReadLine();
Sj = Convert.ToSingle(Sinput);
Sj = Math.Round((Double)Sj, 3);
Console.WriteLine("Please a assign a value for I");
Iinput = Console.ReadLine();
Ij = Convert.ToSingle(Iinput);
if (Ij > 0.00)
{
throw new Exception("No initial condition of recovered needs to be l");
}
Rj = Math.Round((Double)Rj, 3);
Ij = Math.Round((Double)Ij, 3);
Console.WriteLine("Please a assign a value for R");
Rinput = Console.ReadLine();
Rj = Convert.ToSingle(Rinput);
if (Rj != 0)
{
throw new Exception("No initial condition of recovered needs to be set to 0.");
}
Rj = Math.Round((Double)Rj, 3);
if (Math.Abs(Sj + Ij + Rj) != 1)
{
throw new Exception("Sum of the initial conditions must equal to 1.");
}
else
{
Console.WriteLine("The new values for S, I, and R are {0}, {1}, and {2} respectively", Sj, Ij, Rj);
}
}
}
return 0;
}
And here is the method which performs the calculation and stores it into the array. Note that xj represents the stepsize, which will also be in stored.
public double[,] Solve()
{
//data plus one
double Sjp1 = 0;
double Ijp1 = 0;
double Rjp1 = 0;
double[,] Array = new double[numsteps, 4];
//values to modify the stepsize
double xj, xjp1;
xj = x0;
Array[0, 0] = 0;
Array[0, 1] = Sj;
Array[0, 2] = Ij;
Array[0, 3] = Rj;
for (i = 0; i < numsteps; i++) //numstep has bee nset to ten
{
//stepsize has been set to 0.001;
xjp1 = xj + Stepsize; //Updates the stepsize
xj = xjp1;//
Array[i, 0] = xj;
Array[i, 1] = Sj;
Array[i, 2] = Ij;
Array[i, 3] = Rj;
//functions used to calculate Suspected, Infected and Recovered
double f1 = FunctionStore.Suspected(Sj, Ij);
double f2 = FunctionStore.Infected(Sj, Ij);
double f3 = FunctionStore.Recovered(Ij);
Sjp1 = Sj + Stepsize * f1;//Updates the value of Suspected
Sj = Sjp1;
Ijp1 = Ij + Stepsize * f2;//Updates the value of Infected
Ij = Ijp1;
Rjp1 = Rj + Stepsize * f3;//Updates the value of Recovered
Rj = Rjp1;
}
return Array;
}
I've been tweaking things for a while now, but having no success. Was considering of just adding the values directly into the method which writes the file but I would ask if there was a more sophisticated approach that I am missing. Let me know if you need more information.
The variables are stored in the SetInit() function only.
The most common way would be to store the variables outside of the function in class variables.
e.g. private double Sj; and then set them inside of SetInit() with this.Sj = Sj;
Related
How can I make a program in C# that gets 3 digits from the user and outputs the smallest one? It's gonna be as a Console App.
I tried this and gave me an error (I may be stupid):
if (a<b<c)
{
min=a;
Console.WriteLine("Min: " + min);
I don't now what else should I do, I'm new to C#.
There's nothing wrong with being new, and you aren't stupid just because you aren't sure how something works.
Think of it like this:
We need to have a variable to hold this minimum value:
int min;
First, you need to compare two values to get the smallest between them:
if (a < b)
min = a;
else
min = b;
Now that you have the minimum between those two, compare that value to your third input:
if (c < min)
min = c;
If c is less than the current min value, you adjust to c, otherwise you already had your minimum value in the first comparison.
Here is a full example for you to play with as well:
int a = 4;
int b = 2;
int c = 1;
int min;
if (a < b)
min = a;
else
min = b;
if (c < min)
min = c;
Console.WriteLine("Lowest value is {0}", min);
Try this.
if (a < b && a < c)
{
Console.WriteLine("Min: " + a);
}
else if (b < c)
{
Console.WriteLine("Min: " + b);
}
else
{
Console.WriteLine("Min: " + c);
}
Here's a solution that should work:
int a, b, c, min;
Console.WriteLine("Please enter three digits:");
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
c = int.Parse(Console.ReadLine());
min = Math.Min(Math.Min(a, b), c);
Console.WriteLine("Min: " + min);
Just run this code and write if you want me to explain smth. It will be nice if you mark this answer as correct if that's helped you
#region Begin Message
string s = "\"s\"";
Console.WriteLine(#$"Here is example of the code.
Please contact me if you did not understand smth.
You should write as many numbers as u wanna, the program returns numbers in ascending order.
Write {s} to stop
");
#endregion
#region Main Part
List<float> numbers = new List<float>();
while (true)
{
Console.WriteLine($"{numbers.Count + 1} number: ");
string input = Console.ReadLine();
if (input.ToLower().Contains("s"))
{
Console.WriteLine(SortNumbers(numbers) ?? "There are no numbers created");
break;
}
else
{
try
{
float number = float.Parse(input);
numbers.Add(number);
}
catch (Exception ex) { Console.WriteLine("You should write a number \n"); }
}
}
#endregion
string? SortNumbers(List<float> numbers)
{
numbers.Sort();
string? returnedNumbers = null;
if (numbers.Count != 0)
{
returnedNumbers += "\nNumbers: ";
for (int i = 0; i < numbers.Count; i++)
{
returnedNumbers += $"{numbers[i]}, ";
}
}
return returnedNumbers;
}
So I have this code where you enter your "area code" and then you enter how long you would like the call to be. This is basically a simple calculator that would find the cost of how much a call would be depending on your area code. I am having trouble trying to figure out how to keep the loop running if I enter in an invalid area code. As of now if I enter in an invalid area code the entire program will just end in the command prompt. Heres the code:
using System;
using static System.Console;
namespace Chapter6._1
{
class Program
{
static void Main()
{
// array info //
int[] phoneAreacode = { 608, 414, 262, 815, 715, 920 };
double[] phoneCost = { .05, .10, .07, .24, .16, .14 };
// declaring variables //
int x;
int areaCode;
double cost = 0;
int callLength;
bool validAreacode = false;
// start of actual code //
Write("Enter in the area code you want to call: ");
areaCode = Convert.ToInt32(ReadLine());
x = 0;
while (x < phoneAreacode.Length && areaCode != phoneAreacode[x])
++x;
if(x != phoneAreacode.Length)
{
validAreacode = true;
cost = phoneCost[x];
}
if (validAreacode)
{
Write("Enter in the length of your call: ");
callLength = Convert.ToInt32(ReadLine());
double finalCost = callLength * cost;
WriteLine("Your call to area code " + areaCode + " for " + callLength + " minutes will cost " + finalCost.ToString("C"));
}
else
{
WriteLine("YOU MUST ENTER A VALID AREA CODE!");
}
}
}
}
You might wrap your Read and Check routine into another while-loop:
bool validAreacode = false;
while(!validAreacode)
{
// start of actual code //
Write("Enter in the area code you want to call: ");
areaCode = Convert.ToInt32(ReadLine());
x = 0;
while (x < phoneAreacode.Length && areaCode != phoneAreacode[x])
++x;
if(x != phoneAreacode.Length)
{
validAreacode = true;
cost = phoneCost[x];
}
else
{
WriteLine("YOU MUST ENTER A VALID AREA CODE!");
}
}
This is the simplest solution for you (not so much changes in your code required). But your code still has the problems. Your program will be crashed if user tries to print any not digit character instead of area code.
You can do a do-While here:
Basically when you do do-while you force the code on the do to be done until the condition in the while is completed. in your case, you need to add the checking of the pohne number inside the do statement, and to know if the person selected a correct value, you can do Array.FindIndex():
this will be your do-while loop, also i chaned your x for index try to use names for the variables that have some meaning. (index is not perfect anyway)
do
{
Write("Enter in the area code you want to call: ");
areaCode = Convert.ToInt32(ReadLine());
index = Array.FindIndex(phoneAreacode, w => w == areaCode);
if (index >= 0)
{
validAreacode = true;
}
else
{
WriteLine("YOU MUST ENTER A VALID AREA CODE!");
}
} while (!validAreacode);
and this will be your entire main method:
int[] phoneAreacode = { 608, 414, 262, 815, 715, 920 };
double[] phoneCost = { .05, .10, .07, .24, .16, .14 };
// declaring variables //
int index;
int areaCode;
int callLength;
bool validAreacode = false;
// start of actual code //
do
{
Write("Enter in the area code you want to call: ");
areaCode = Convert.ToInt32(ReadLine());
index = Array.FindIndex(phoneAreacode, w => w == areaCode);
if (index >= 0)
{
validAreacode = true;
}
else
{
WriteLine("YOU MUST ENTER A VALID AREA CODE!");
}
} while (!validAreacode);
Write("Enter in the length of your call: ");
callLength = Convert.ToInt32(ReadLine());
double finalCost = callLength * phoneCost[index];
WriteLine("Your call to area code " + areaCode + " for " + callLength + " minutes will cost " + finalCost.ToString("C"));
As you can see you can also remove the while you have to loop the array and the if-else for the valid codes. assuming that when the code reach that point, the area is correct.
It's a good practice to try to remove the number of if-else.
You probably need to loop the entire code section, something like this
while (true)
{
Write("Enter in the area code you want to call: ");
var input = ReadLine();
if (input == "Exit")
break;
areaCode = Convert.ToInt32(input);
x = 0;
while (x < phoneAreacode.Length && areaCode != phoneAreacode[x])
++x;
if(x != phoneAreacode.Length)
{
validAreacode = true;
cost = phoneCost[x];
}
else if (validAreacode)
{
Write("Enter in the length of your call: ");
callLength = Convert.ToInt32(ReadLine());
double finalCost = callLength * cost;
WriteLine("Your call to area code " + areaCode + " for " + callLength + " minutes will cost " + finalCost.ToString("C"));
}
else
{
WriteLine("YOU MUST ENTER A VALID AREA CODE!");
}
}
Don't forget to add a check for when user types something that's not a digit
I'm having a hard time wrapping my mind around this. Every time the player makes a wrong guess, it should subtract his/her bet from the initial balance.
Since it is in a loop, it always takes the initial balance from the beginning spits out the same balance every time. (obviously)
I've tried assigning different variables and just can't seem to figure it out.
I've omitted the medium and hard difficulty methods as they are of no use right now, until I figure out this one.
My Main() only calls the setDifficulty(). Nothing else.
class Control
{
int selectedNumber = 0;
Random num = new Random();
bool playAgain = true;
int difficulty = 0;
int bet = 0;
int initialBalance = 20;
int runningCredits = 0;
int credits = 0;
public Control()
{ }
//sets game difficulty
public void SetDifficulty()
{
Console.Clear();
Console.WriteLine("Please select level of difficulty between 1 - 100");
difficulty = int.Parse(Console.ReadLine());
if (difficulty >= 1 && difficulty <= 20)
LetsPlayEasy();
else if (difficulty >= 21 && difficulty <= 50)
LetsPlayMedium();
else if (difficulty >= 51 && difficulty <= 100)
LetsPlayHard();
else
{
SetDifficulty();
}
}
//easy level method
public void LetsPlayEasy()
{
//variables
int userGuess;
int numGuesses = 0;
selectedNumber = num.Next(1, 101);
Console.BackgroundColor = ConsoleColor.DarkYellow;
Console.Clear();
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Difficulty level = EASY");
Console.WriteLine("\nBeggining credit balance = " + initialBalance);
Console.WriteLine("\nPlease place a bet. You will lose those credits for every incorrect guess!");
bet = int.Parse(Console.ReadLine());
do
{
Console.WriteLine("\nGuess a number between 1 and 100.");
userGuess = Convert.ToInt32(Console.ReadLine());
numGuesses++;
UI output = new UI();
output.CompareNumbers(userGuess, ref selectedNumber, ref playAgain, ref numGuesses);
runningCredits = (initialBalance - bet);
Console.WriteLine("\nYou have " + runningCredits + " credits remaining.");
} while (playAgain == true);
}
class UI
{
Random num = new Random();
int keepGoing;
public UI()
{ }
//compare user's guess to selected number
public void CompareNumbers(int userGuess, ref int selectedNumber, ref bool playAgain, ref int numGuesses)
{
Control difficulty = new Control();
Admin say = new Admin();
if (userGuess > selectedNumber)
{
Console.Beep(600, 300);
Console.WriteLine("\nToo High! Guess Again!");
}
else if (userGuess < selectedNumber)
{
Console.Beep(300, 300);
Console.WriteLine("\nToo Low! Guess Again!");
}
else
{
Console.Beep(350, 300);
Console.Beep(380, 200);
Console.Beep(380, 100);
Console.Beep(500, 1100);
Console.WriteLine("\n\nCongrats! It took you " + numGuesses + " guesses to win.");
numGuesses = 0;
Console.WriteLine("Press 1 to play again or 2 to quit.");
keepGoing = int.Parse(Console.ReadLine());
while (keepGoing != 1 && keepGoing != 2)
{
Console.WriteLine("\n\nPlease type either 1 or 2 only!");
keepGoing = int.Parse(Console.ReadLine());
}
if (keepGoing == 2)
{
playAgain = false;
say.Goodbye();
}
else
{
Console.Clear();
difficulty.SetDifficulty();
}
}
}
}
}
Initialise runningBalance to initialBalance and only use this value for calculations. If you only need initialBalance once, you can also do it by simply switching runningBalance to initialBalance without initializing runningBalance.
Console.WriteLine("\nBeggining credit balance = " + initialBalance);
Console.WriteLine("\nPlease place a bet. You will lose those credits for every incorrect guess!");
bet = int.Parse(Console.ReadLine());
runningBalance = initialBalance
do
{
Console.WriteLine("\nGuess a number between 1 and 100.");
userGuess = Convert.ToInt32(Console.ReadLine());
numGuesses++;
UI output = new UI();
output.CompareNumbers(userGuess, ref selectedNumber, ref playAgain, ref numGuesses);
runningCredits -= bet;
Console.WriteLine("\nYou have " + runningCredits + " credits remaining.");
} while (playAgain == true);
runningCredits = (initialBalance - bet);
You don't change initialBalance or bet in the loop, so every iteration has the same value of runningCredits.
Outside the loop, do this:
runningCredits = initialBalance;
Inside the loop, do this:
runningCredits -= bet;
Note: you don't have any code to check in the loop to see if the user guessed right or wrong (and as such, the user always loses and you always subtract out the bet).
So I am doing a homework assignment and for some reason my variable is not giving me the correct output. Using 6, 7, 8, 9, 10 as the judge scores and 1.2 as the degree of difficulty, I should receive 9.6 back for the final dive score.. but for some reason I am receiving 8.. Any ideas?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rickerson_Bret_iLab3
{
class Program
{
static void Main(string[] args)
{
string wouldContinue;
do
{
string diverName;
string diverCity;
double degreeofDiff = 0;
double scoreJudge = 0;
bool validDegree = false;
double totalJudgeScore = 0;
int i = 1;
double highJudgeScore = 0;
double lowJudgeScore = 0;
Console.WriteLine("Enter the diver's name...");
diverName = Convert.ToString(Console.ReadLine());
Console.WriteLine("Enter the diver's city...");
diverCity = Convert.ToString(Console.ReadLine());
while (validDegree == false)
{
Console.WriteLine("Enter the degree of difficulty for this dive...");
degreeofDiff = Convert.ToDouble(Console.ReadLine());
if (degreeofDiff < 1.00 || degreeofDiff > 1.67)
{
Console.WriteLine("Re-enter a valid degree of difficulty (Valid Range: 1.00 - 1.67");
validDegree = false;
}
else
{
validDegree = true;
}
}
while (i < 6)
{
Console.WriteLine("Enter the judge #" + i + " score...");
scoreJudge = Convert.ToDouble(Console.ReadLine());
if (scoreJudge > 10 || scoreJudge < 1)
{
bool validScore = false;
while (validScore == false)
{
Console.WriteLine("Enter a valid Judge Score for judge #" + i + "...");
scoreJudge = Convert.ToDouble(Console.ReadLine());
if (scoreJudge > 10 || scoreJudge < 1)
{
validScore = false;
}
else
{
validScore = true;
}
}
}
if (scoreJudge > highJudgeScore)
{
highJudgeScore = scoreJudge;
Console.WriteLine(highJudgeScore);
}
if (scoreJudge < lowJudgeScore)
{
lowJudgeScore = scoreJudge;
Console.WriteLine(lowJudgeScore);
}
i++;
totalJudgeScore = totalJudgeScore + scoreJudge;
Console.WriteLine(totalJudgeScore);
Console.WriteLine(scoreJudge);
}
double highLow = highJudgeScore + lowJudgeScore;
totalJudgeScore = totalJudgeScore - highLow;
totalJudgeScore = (totalJudgeScore / 3) * degreeofDiff;
Console.WriteLine("Diver: " + diverName);
Console.WriteLine("Diver City: " + diverCity);
Console.WriteLine("Dive Degree of Difficulty: " + degreeofDiff);
Console.WriteLine("Dive Score: " + totalJudgeScore);
Console.WriteLine("Would you like to enter another diver? Enter y for yes or n for no...");
wouldContinue = Convert.ToString(Console.ReadLine());
wouldContinue.ToUpper();
} while (wouldContinue == "Y");
}
}
}
I want to add. I attempted to verify that it was accepting the data correctly by having it display the variables as it went through or anytime the variable was manipulated...it appears to be correct throughout but at the end is when I have the issue with variable "totalJudgeScore"
Edit2: I have since found that for some reason the code is not following the last 2 if statements properly. It is storing "scoreJudge" to "highJudgeScore" and "lowJudgeScore" each time and overwriting the data incorrectly.
Your lowJudgeScore is never getting set after it gets set to 0. You should have it default to 10 or higher, so that it gets set correctly.
Try this:
double lowJudgeScore = 10.0;
What happens is that the lowJudgeScore is never set during the loop. Add this else block and to initialize the lowJudgeScore...
if (scoreJudge < lowJudgeScore)
{
lowJudgeScore = scoreJudge;
Console.WriteLine(lowJudgeScore);
}
//Add this else block to initialize the low score variable
else if (lowJudgeScore == 0)
{
lowJudgeScore = scoreJudge;
}
I have created a c# program that takes a scan input, and then takes the information from the input. What I have been noticing is that for larger strings, my program for some reason splits the string into two parts (not in half), which screws up the way I get my information. My string has hexadecimal values in it as well.
For example, when I scan a code into my console, it reads the string
[)>065JUN1234567892300167Q205GT21L123 ABC06P123456787Q100PL7Q10PKQ1006P98356877Q100PL7Q5PKQ2006P235265437Q200PL7Q40PKQ5
but it splits that string into:
[)>065JUN1234567892300167Q205GT21L123 ABC06P123456787Q100PL7Q10PKQ1006P98356877Q100"
and
PL7Q5PKQ2006P235265437Q200PL7Q40PKQ5
Any idea how to fix this, or allocate more memory to my variable which reads the console for the input scan?
Here is my code, its kind of long.
static void Main(string[] args)
{
Console.WriteLine("Please enter the date and lane number");
Console.WriteLine("like so: ddmmyylanenumber.");
string lanenum = Console.ReadLine();
Console.WriteLine("When done scanning, please type");
Console.WriteLine("\"finish\" into the console.");
string scanInput;
do
{
Console.Write("Scan now:");
scanInput = Console.ReadLine();
//The number before "JUN" identifies the type of label it is.
int posOfJUN = scanInput.IndexOf("JUN");
//Finding the type of label
string typeOfLabel = scanInput.Substring(posOfJUN - 1, 1);
string label;
if (typeOfLabel == "5")
{
label = "mixed";
}
else if (typeOfLabel == "1")
{
label = "individual";
}
else
{
label = null;
}
switch (label)
{
case "individual":
partNumber = scanInput.Substring(8, 8);
int posOfQ1 = scanInput.IndexOf("Q");
int posOf1JUN = scanInput.IndexOf("1JUN");
//Quantity of the pack
total = scanInput.Substring(posOfQ1 + 1, posOf1JUN - posOfQ1 - 1 - 1);
//number of packs is 1 because individual
numOfPacks = "1";
dunsNumber = scanInput.Substring(posOf1JUN + 4, 9);
//used to find the duns and serial number
posOf20L = scanInput.IndexOf("20L");
posOf21L = scanInput.IndexOf("21L");
//Setting the serial number
if (posOf21L == -1 || posOf20L < posOf21L)
{
serialNumber = scanInput.Substring(posOf1JUN + 4, posOf20L - posOf1JUN - 4 - 1);
}
else if (posOf20L == -1 || posOf21L < posOf20L)
{
serialNumber = scanInput.Substring(posOf1JUN + 4, posOf21L - posOf1JUN - 4 - 2);
}
else
{
serialNumber = null; //else clause if serial number can't be created
Console.WriteLine(new ArgumentException("Error obtaining Serial Number"));
}
partObject part2 = new partObject(partNumber, total, numOfPacks);
newPacks = int.Parse(numOfPacks);
total = total.ToString();
newtotal = int.Parse(total);
part2.callSQL(partNumber, newtotal, newPacks, dunsNumber, serialNumber, lanenum);
break;
case "mixed":
posOfJUN = scanInput.IndexOf("JUN");
dunsNumber = scanInput.Substring(posOfJUN + 3, 9);
int posOf7Q = scanInput.IndexOf("7Q");
posOf20L = scanInput.IndexOf("20L");
posOf21L = scanInput.IndexOf("21L");
//Finding serial number
serialNumber = scanInput.Substring(posOfJUN + 3, posOf7Q - posOfJUN - 3);
//The following lines are to find how many different parts are in the mixed load.
posOfPK = scanInput.IndexOf("PK");
int PKTemp;
int parts = 1;
//Each time a "PK" is seen, it means there is another part so the count increments.
while (scanInput.IndexOf("PK", posOfPK + 1) != -1)
{
PKTemp = scanInput.IndexOf("PK", posOfPK + 1);
posOfPK = PKTemp;
parts++;
}
//Creating an array of size "parts"
int posOf06 = scanInput.IndexOf("06");
int temp06 = scanInput.IndexOf("06", posOf06 + 2);
posOf06 = temp06;
int indexOfP = scanInput.IndexOf("P", posOf06 + 1);
partNumber = scanInput.Substring(indexOfP + 1, 8);
posOfPK = scanInput.IndexOf("PK", indexOfP);
posOfPL = scanInput.IndexOf("PL", indexOfP);
posOf7Q1 = scanInput.IndexOf("7Q", indexOfP);
partObject[] arrayOfParts = new partObject[parts];
for (int i = 0; i < parts; i++)
{
//Finds the different values, creates an object and puts it into the array of parts
partNumber = scanInput.Substring(indexOfP + 1, 8);
total = scanInput.Substring(posOf7Q1 + 2, posOfPL - posOf7Q1 - 2);
numOfPacks = scanInput.Substring(posOfPL + 5, posOfPK - posOfPL - 5);
arrayOfParts[i] = new partObject(partNumber, total, numOfPacks);
//resetting the variables for the next iteration, so a new object can be created with the next part
posOf06 = scanInput.IndexOf("06", temp06 + 1);
indexOfP = scanInput.IndexOf("P", posOf06 + 1);
temp06 = posOf06;
posOfPK = scanInput.IndexOf("PK", indexOfP);
posOfPL = scanInput.IndexOf("PL", indexOfP);
posOf7Q1 = scanInput.IndexOf("7Q", indexOfP);
//putting each object into SQL
newtotal = int.Parse(total);
newPacks = int.Parse(numOfPacks);
serialNumber = serialNumber + "P" + (i + 1);
arrayOfParts[i].callSQL(partNumber, newtotal, newPacks, dunsNumber, serialNumber, lanenum);
}
break;
default:
break;
}
}
} while (scanInput != "finish");
}
The full string is never there right from the start of the code.
If you debug your program I think you will find that the string is all there.
I'm not sure why you think the string is split... a System.String can only hold one string. At some point are you getting a string[] ?
Place a breakpoint after this line scanInput = Console.ReadLine(); and in Visual Studio hover over scanInput, and it will show you the whole string.... or try just printing out the string to show that it is all there.
EDIT: If you're using hexadecimal, try looking up the hex values which cause the anomaly on the ascii table. Perhaps the hex value is resulting in a carriage return or newline.