Jump to content

Newbie Needs help

- - - - -

  • Please log in to reply
13 replies to this topic

#1
johnson6226

johnson6226

    Newbie

  • Members
  • Pip
  • 8 posts
Hello
My name is Richard, i am new into C #, i do self study and i have been working on creating a GUI and code for the attached work but i don't seem to get it.


I am trying to Create an appropriate GUI to enter information for at least 10 students. For each student, i have to enter the following information: student ID number, student’s first and last names, date of birth consisting of day, month and year and an average mark.

Then i need to Create a separate class Student, containing student’s information in the form: student ID number, student’s first and last name, day, month and year of birth and average mark. The class should have constructors, properties and methods. Store the information about all the students in an array of type Student. After reading from the GUI the information about a particular student, create an object of class Student (element of the array) with the relevant constructor.

I am having problems, I would be very grateful if any of you can help me.

Richard

#2
tormaroe

tormaroe

    Newbie

  • Members
  • PipPip
  • 15 posts

Quote

i have been working on creating a GUI and code for the attached work but i don't seem to get it.

Please be more precise about what you have actually done and what you can't make work. Do you get any specific errors? Don't you know how to create classes/objects? ...

#3
johnson6226

johnson6226

    Newbie

  • Members
  • Pip
  • 8 posts
I created the GUI, with 4 labels, 4 texboxes and a button.
Label1 = Firstname
Label2 = Lastname
Label3 = Date of birth
Label 4 = ID Number
Button = Check data.

When i click on the button to generate the code, i am stucked, i get too many errors..

Please help.

Thanks

#4
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 242 posts
I'm having a hard time seeing your monitor from over here, so why don't you post the code that is causing the error, the error message you are getting and why you think you are getting that error?

#5
johnson6226

johnson6226

    Newbie

  • Members
  • Pip
  • 8 posts
thanks
Here is the code i dont know what i am doing wrong

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public class StudentClass
{
private void button1_Click(object sender, EventArgs e);


public string FirstName { get; set; }
public string LastName { get; set; }
public int StudentID { get; set; }
public int DateofBirth { get; set; }
public List<int> ExamScores;
}

protected static List<Student> students = new List<Student>
{
new Student {FirstName = "Tom", LastName = "Adams", StudentID = 120,
DateofBirth = 1970/03/02,
ExamScores = new List<int>{ 99, 82, 80, 74}},
new Student {FirstName = "radi", LastName = "Fakhouri", StudentID = 116,
DateofBirth = 1960/03/10,
ExamScores = new List<int>{ 88, 86, 90, 94}},
new Student {FirstName = "help", LastName = "Feng", StudentID = 117,
DateofBirth = 1990/03/02,
ExamScores = new List<int>{ 93, 92, 80, 87}},
new Student {FirstName = "Cesar", LastName = "Garcia", StudentID = 114,
DateofBirth = 1990/03/12,
ExamScores = new List<int>{ 97, 89, 85, 82}},
new Student {FirstName = "rose", LastName = "Garcia", StudentID = 115,
DateofBirth = 1990/03/02,
ExamScores = new List<int>{ 35, 72, 91, 70}},
new Student {FirstName = "henry", LastName = "Garcia", StudentID = 118,
DateofBirth = 1990/03/02,
ExamScores = new List<int>{ 92, 90, 83, 78}},
new Student {FirstName = "jan", LastName = "Mortensen", StudentID = 113,
DateofBirth = 1980/03/02,
ExamScores = new List<int>{ 88, 94, 65, 91}},
new Student {FirstName = "boyle", LastName = "O'Donnell", StudentID = 112,
DateofBirth = 1991/03/02,
ExamScores = new List<int>{ 75, 84, 91, 39}},
new Student {FirstName = "Sera", LastName = "Omelchenko", StudentID = 111,
DateofBirth = 1930/03/02,
ExamScores = new List<int>{ 97, 92, 81, 60}},
new Student {FirstName = "Lance", LastName = "Tucker", StudentID = 119,
DateofBirth = 1950/03/02,
ExamScores = new List<int>{ 68, 79, 88, 92}},

};

}



}



ERROR MESSAGES


Error 1 The type or namespace name 'Student' could not be found (are you missing a using directive or an assembly reference?) c:\users\richard\documents\visual studio 2010\Projects\WindowsFormsApplication5\WindowsFormsApplication5\Form1.cs 31 27 WindowsFormsApplication5

#6
tormaroe

tormaroe

    Newbie

  • Members
  • PipPip
  • 15 posts
Ok, so the error message says it can't find "Student". Does it exist?

Have you written this code yourself btw?

PS: With a basic problem like this, you would find the solution much quicker by googling the error message then asking us. But keep the questions coming, you will become better at asking soon.

#7
johnson6226

johnson6226

    Newbie

  • Members
  • Pip
  • 8 posts
Anyway, thanks for your answers so far, i think i will have to find the solutions by myself. It wasn't easy for me to post my questions because i felt you all might think it's a home work which is not. In regards to wheather i wrote the code by myself, not really, i took an example from the internet to write my code but still not working.

Thanks i thought i could get help from you guys...

#8
Simonxz

Simonxz

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
Replace Student by StudentClass. The name of your class is StudentClass, not Student.

#9
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 242 posts

Simonxz said:

Replace Student by StudentClass. The name of your class is StudentClass, not Student.
Technically he should replace StudentClass with Student, as it says in the problem description (Create a separate class Student)

#10
johnson6226

johnson6226

    Newbie

  • Members
  • Pip
  • 8 posts
Thanks for all your posts....it seems i would have to figure out the solution myself....Thanks

#11
johnson6226

johnson6226

    Newbie

  • Members
  • Pip
  • 8 posts
I am trying to work out another way of designing my GUI.

I want to use the ShowInputDialog method. What i trying to do now is, i have created a GUI with 2 buttons, Start and Cancel.

If the Start button is clicked, a ShowInputDialog would appear, requesting for a specific information (e.g First name and Last name).

If the next button in this ShowInputDialog is clicked, another ShowInputDialog would appear until all the information wanted has been reached.

If the next button in this final ShowInputDialog is clicked and all the information are true, a MessageBox.Show would appear dispalying a message.

Now my question is,

What is the code for the Start and Cancel button?..I mean if the Start button is clicked, my ShowInputDialog should appear and if the Cancel button is clicked GUI closes.

Finally, how do i write the code so that this ShowInputDialog comes up until i stop it ?

Thanks

#12
johnson6226

johnson6226

    Newbie

  • Members
  • Pip
  • 8 posts
Could it be there is no ShowInputDialog in C #?.....all the info i found was related to Java.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users