So I have a school assignment and yeah I'm nooby at C# still. Worked on this assignments for a few days and I still don't know how to make it fully work =/ Can someone please help me with some simple codes or something? Even just a tiny bit of the program that I didn't manage would help.
=======[Assignment]=======
=======[My Code so far]=======Code:The student council at Central Canada Collegiate is preparing signs with the message WELCOME TO CCC GOOD LUCK TODAY on various walls around the school. A sign is wide enough to hold w characters on each row, including spaces, as befits the wall to be decorated. Here is how the words are put onto a sign. First, as many words as possible are placed on the first line, without exceeding the w character limit. The first word in the line begins in the leftmost position. If there is more than one word in the line, the last word ends in the rightmost position. Extra spaces are inserted into the gaps between the words so that the gaps are as similar as possible.If the gaps cannot be made equal, all of the larger gaps should appear to the left of the smaller ones. Subsequent lines are constructed in the same way. Your program will read the available width w and output the sign on the screen. Use the “.” character to indicate a space. Constraints You may assume that w >= 7. Sample Input 1 (user inputs are shown in italics) Enter w: 7 Output for Sample Input 1 WELCOME TO..CCC GOOD... LUCK... TODAY.. Sample Input 2 (user inputs are shown in italics) Enter w: 10 Output for Sample Input 2 WELCOME.TO CCC...GOOD LUCK.TODAY Sample Input 3 Enter w: 13 Output for Sample input 3 WELCOME....TO CCC.GOOD.LUCK TODAY........
Code:String input; int i, count; public ArraySignage() { InitializeComponent(); } private void buttonAdjustSize_Click(object sender, EventArgs e) { try //Tries to see if user inputed a valid size limit { if (textBoxSubmitText.Text.Contains(" ")) { String[] x = new String[count++]; int size = int.Parse(textBoxAdjustSize.Text); int temp = input.IndexOf(" "); /*while (input.Length >= 0) //This loop checks positions of spaces { x[i] = input.Substring(0, temp - 1); input = input.Substring(temp + 1, input.Length - (temp + 1)); i++; }*/ while (temp >= 0) { if (temp >= 0) { x[i] = input.Substring(0, temp--); input = input.Substring(temp++, input.Length - (temp++)); } else { x[i] = input; } i++; } } } catch (FormatException) //If it isn't valid it won't work { MessageBox.Show("Please put a valid size."); } } private void Form1_Load(object sender, EventArgs e) { buttonAdjustSize.Hide(); textBoxAdjustSize.Hide(); } private void buttonSubmitText_Click(object sender, EventArgs e) { if (textBoxSubmitText.Text != "") //Checks if user inputed text { input = textBoxSubmitText.Text; label1.Text = "User Input: " + input; buttonAdjustSize.Show(); textBoxAdjustSize.Show(); buttonSubmit.Hide(); textBoxSubmitText.Hide(); } else //If user didn't this shows and the user is forced to input text { MessageBox.Show("Please insert sentence."); } }
Results 1 to 3 of 3
Thread: [C#] Need Homework Help x_x
- 05 Apr. 2010 04:30pm #1
[C#] Need Homework Help x_x
- 07 Apr. 2010 05:39pm #2
I'll look at your code.
But, Im not doing your homework for you.
- 07 Apr. 2010 08:58pm #3
lol im done like half of it
ill take whatever help i can get since this damn assignment took me over a week and still lost