Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,562 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,898 people online right now. Registration is fast and FREE... Join Now!




an easy programme but i am a begnier

 
Reply to this topicStart new topic

an easy programme but i am a begnier, Control Sheet

sezeef
16 May, 2008 - 04:51 AM
Post #1

New D.I.C Head
*

Joined: 14 May, 2008
Posts: 2

a program that stores the data of students in a certain year, such as seat number, name, address and marks in each course. The program should:
· Add a new student
· Edit the data of a certain student.
· Calculate the total mark and grade of a certain student.
· Search for a certain student and display his data.
· Calculate the average marks of students in a certain course.


User is offlineProfile CardPM
+Quote Post

KYA
RE: An Easy Programme But I Am A Begnier
16 May, 2008 - 04:56 AM
Post #2

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 4,924



Thanked: 105 times
Dream Kudos: 1200
My Contributions
Ta Da!

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
User is offlineProfile CardPM
+Quote Post

skater_00
RE: An Easy Programme But I Am A Begnier
16 May, 2008 - 06:03 AM
Post #3

D.I.C Head
Group Icon

Joined: 30 Apr, 2008
Posts: 173



Thanked: 4 times
Dream Kudos: 50
My Contributions
Show us your programming effort first by providing code, before we can help you. A good thing to do here would be to write your program in pseudocode in the first place.
User is offlineProfile CardPM
+Quote Post

Codegamer
RE: An Easy Programme But I Am A Begnier
16 May, 2008 - 10:19 AM
Post #4

D.I.C Head
**

Joined: 4 May, 2008
Posts: 127


My Contributions
Exactly lol smile.gif
User is offlineProfile CardPM
+Quote Post

Codegamer
RE: An Easy Programme But I Am A Begnier
16 May, 2008 - 02:26 PM
Post #5

D.I.C Head
**

Joined: 4 May, 2008
Posts: 127


My Contributions
Sorry for my bad comment crazy.gif
User is offlineProfile CardPM
+Quote Post

KYA
RE: An Easy Programme But I Am A Begnier
16 May, 2008 - 03:34 PM
Post #6

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 4,924



Thanked: 105 times
Dream Kudos: 1200
My Contributions
It was pretty good
User is offlineProfile CardPM
+Quote Post

sezeef
RE: An Easy Programme But I Am A Begnier
17 May, 2008 - 06:43 PM
Post #7

New D.I.C Head
*

Joined: 14 May, 2008
Posts: 2

this is the code and srry for my delay:



#include <iostream>
#include <string>
using namespace std;

struct student
{
int seatnumber;
string name;
string adress;
float marks[6];
};
void input(int i,student s[])
{
cout<<endl;
cout<<"Enter the name of student("<<i+1<<"):";
cin<<s[i].seatnumber;
cin.ignore();
cout<<"Enter the name of student("<<i+1<<"):";
getline(cin,s[i].name);
cout<<"Enter the adress of student("<<i+1<<"):";
getline(cin,s[i].adress);
cout<<"Enter 6 marks of student ("<<i+1<<"):";
for(int i=0;i<6;i++)
{
cin>>s[i].marks[i];
}
}
void edit(student s[],int i)
{
int choice;
char again;
do
{
cout<<"\n to edit the seat number of student("<<i+1<<"):(press 1)";
cout<<"\n to edit the name of student("<<i+1<<"):(press 2)";
cout<<"\n to edit the adress of student("<<i+1<<"):(press 3)";
cout<<"\n to edit the marks of student("<<i+1<<"):(press 4)";
cout<<"\n\n Enter the number u want to do:";
cin>>choise;
switch(choise)
{
case 1:
{
cout<<"\n Enter the new seat number of student ("<<i+1<<"):";
cin>>s[i].seatnumber;
break;
}
case 2:
{
cout<<"\n Enter the new name of student ("<<i+1<<"):";
cin>>s[i].ignore();
getline(cin,s[i].name);
break;
}
case 3:
{
cout<<"\n Enter the new adress of student ("<<i+1<<"):";
cin>>s[i].ignore();
getline(cin,s[i].adress);
break;
}
case 4:
{
cout<<"\Enter the new marks of student("<<i+1<<")"
for(int h=0;h<6;h++);
{
cin>>s[i].marks[h];
}
break;
}
default:
cout<<"\n Error!!\n u must choice (1 or 2 or 3 or 4)\n";
}
cout<<"\n do u want edit another data in this student (y or n):";
{
cin>> again;
}
while(again!='n');
}
void output(int i,student s[])
{
cout<<"\n";
cout<<"the seat number of student("<<i+1<<")is:";
cout<<s[i].seatnumber;
cout<<"the name of student("<<i+1<<")is:";
cout<<s[i].name;
cout<<"the adress of student("<<i+1<<")is:";
cout<<s[i].adress;
cout<<endl;
cout<<"the 6 marks of student("<<i+1<<")is:\n";
for(int i=0;i<6;i++)
{
cout<<s[i].marks[i]<<endl;
}
}
void main()
{
int n_students;
int choice;
char again;
cout<<"Enter the number of students:";
cin>>n_students;
student *s;
s=new student [n_students];
//input student
for (int i=0;i<n_students;i++)
{
input(i,s);
}
do
{
//choice of equation
cout<<"\n\n\n";
cout<<"to add a new student(press 1)\n";
cout<<"to edit the data of student(press 2)\n";
cout<<"to calculate the total marks or grades of a certain student(press 3)\n";
cout<<"to search for student any display his data (press 4)\n";
cout<<"to calculate the avarge marks of student in a certain course (press 5)\n";
cout<<"\n Enter the number u want to do:";
cin>>choice;
switch (choice)
{
case 1:
{
student *temp;
temp = new student[n_student];
for(int t=0;t<n_student;t++)
{
temp[t]=s[t];
}
delete[]s;
n_student=n_student+1;
s=new student[n_student];
for(int t=0;t<n_student-1;t++)
{
s[t]=temp[t];
}
input(n_students-1,s);
break;
}
case 2:
{
int n_edit,counter;
cout<<"\n Enter teh seat number of student u want to edit:";
cin>>n_edit;
for(counter=0;counter<n_student;counter++)
{
if(s[counter].seatnumber==n_edit)
break;
}
edit(s,counter);
break;
}
case 3:
{
int n_total,r;
float total=0;
cout<<"\n enter the seat number of student u want to calculate the total marks:";
cin>>n_total;
for(r=0;r<n_student;r++)
{
if(s[r].seatnumber==n_total)
break;
}
for(int j=0;j<6;j++)
{
total+=s[r].marks[j];
}
cout<<"the total marks of student("<<r+1<<")is:"<<total<<endl;
break;
}
case 4:
{
int n_search,p;
cout<<"\n Enter the seat number of student u want to search:";
cin>>n_search;
for(p=0;p<n_student;p++)
{
if(s[p].seatnumber==n_search)
break;
}
cout"\n the date of this student is:\n";
output(p,s);
break;
}
case 5:
{
int sum=0,number;
cout<<"\n what is the number of course that u want calculate the average marks of student in it\n";
cin>>number;
for(int h=0;h<n_students;h++)
{
sum+=[h].marks[number-1];
}
float avg =sum/6.0;
cout<<sum/n_students<<endl;
break;
}
default:
{
cout<<"\n Error !! \n u must choice(1 or 2 or 3 or 4 or 5)\n";
}
}
cout<<"\n \n whould you like to do another operation (y/n):"<<endl;
cin>>again;
}
while (again != 'n');
delete []s;
}
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 11:43PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month