DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Please help in this program array (http://www.daniweb.com/forums/thread105264.html)

CE Student Jan 18th, 2008 12:37 pm
Please help in this program array
 
Hi!
I am a new member here
and I want any body to help me in this program
becuase I am a new student in c++
and I don not now a lot in it
sorry for my wrong language, because I do not speak English very will
please help me
I should sent this program tomorow



(Airplane Seating Assignment) Write a program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with 6 seats in each row. Rows 1 and 2 are first class; the remaining rows are economy class. Also, rows 1 through 7 are nonsmoking. Your program must prompt the user to enter the following information:
Ticket type (first class or economy class) For economy class, the smoking or nonsmoking section Desired seat Output the seating plan in the following form:

A B C D E F
Row 1 * * X * X X
Row 2 * X * X * X
Row 3 * * X X * X
Row 4 X * X * X X
Row 5 * X * X * *
Row 6 * X * * * X
Row 7 X * * * X X
Row 8 * X * X X *
Row 9 X * X X * X
Row 10 * X * X X X
Row 11 * * X * X *
Row 12 * * X X * X
Row 13 * * * * X *

Here , * indicates that the seat is available; X indicated that the seat is occupied. Make this a menu-driven program; show the user’s choices and allow the user to make the appropriate choice.

CE Student Jan 18th, 2008 12:38 pm
Re: Please help in this program array
 
This is my try
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main()
{
        string nameofstd[50];//name of student
        double stdtestscore[50];//student test score
        double sum=stdtestscore[0];
        double larger=stdtestscore[0];
        int M;
        double avg;
        int counter=0;
        ifstream infile;
        infile.open("in.txt");
        while(!infile.eof() && counter<=50)
        {
        infile>>nameofstd[counter]>>stdtestscore[counter];
        counter++;
        }
        counter--;
        for(int i=0;i<counter;i++)
        {
                sum+=stdtestscore[i];
                M=0;
                if(stdtestscore[i]>larger)
                {
                        larger=stdtestscore[i];
                        M=i;
                }
        }

        avg=sum/counter;

        cout<<"average="<<avg<<endl;
       
                        cout<<"The students thier test scores are below the class average"<<endl;//an appropriate message
                        cout<<"students are:"<<endl;
                        for(int Z=0;Z<counter;Z++)
                        {
                                if(stdtestscore[Z]<avg)
                                        cout<<nameofstd[Z]<<endl;
                        }
                        cout<<"The Highest test score is:"<<larger<<endl;
                        cout<<"The student whose have the highest test score are:"<<endl;

                                for(int A=0;A<counter;A++)
                                {
                                        if(stdtestscore[A]==larger)
                                                cout<<nameofstd[A]<<endl;
                                }
        infile.close();
        return 0;
}

CE Student Jan 18th, 2008 12:39 pm
Re: Please help in this program array
 
There is any thing wrong??????

Narue Jan 18th, 2008 1:53 pm
Re: Please help in this program array
 
>There is any thing wrong??????
Yes, you forgot to add code tags despite having instructions thrown in your face with every post. I've added them for you this time.

CE Student Jan 19th, 2008 4:47 am
Re: Please help in this program array
 
Why there is no answer
please help me
This pogram 100 mark for it
:(

smile! Jan 19th, 2008 4:58 am
Re: Please help in this program array
 
Hello!
How we can help you and your program that you trid to did it is different and the program question is differint !
your program about airplain and your program about students and scores!

Salem Jan 19th, 2008 8:14 am
Re: Please help in this program array
 
> double sum=stdtestscore[0];
What will the value of sum be before you've read data into stdtestscore[0]?
What will the value of sum be AFTER you've read data into stdtestscore[0]?

> while(!infile.eof() && counter<=50)
If counter is 50, will that overflow your array?

And smile! is correct, your question and your answer have no relationship.


All times are GMT -4. The time now is 4:59 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC