Hi I was assigned a project in my C++ class. the project is to write a program using arrays. I have to write it for a plane that has 15 seats. Seat 1 to 7 is first class and seat 8 to 15 is economy. The program should be able to prompt the use to enter "E" of "F". E will assign first economy seat and F will assign first class. The program has to be able to assign any empty seat either in economy or first class if all the seats are filled in the users first choice (fist class or economy. please help me I have no clue what to do with the coding for this program.

Please I need instructions or an example of what to do. i have never taken a programming class in my life. the only thing I know is cin and cout and to top it off almost all the other students in the class have a sollid background in C programming so they are catching on with ease. Also i did strat writing the program I will send it you. unfortunately i do not have it on this system.

>i have never taken a programming class in my life.
Talk to your teacher about this. C++ is a bit difficult for a beginner, and if everyone else in your class has already had some experience with C (or another programming language of some kind), you are going to find yourself falling behind. No offense, but perhaps you shouldn't be taking this course?

If you have a specific question about your assignment, that's fine, but realistically, we can't really teach you how to code the entire assignment...

By all means post what you've written so far, but be sure to put [code=cplusplus] in front of your code, and [/code] after it, so that it's readable.

This is what I have written so far but I keep getting error messages! any ideas?

#include "stdafx.h"
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
 
 
int x[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
char e, f;
int total = 0;
int seat_found = 0;
int I;
int main (void)
{
{cout <<"Enter E for Economy or F for first class: " ;
cin >> e || f;}
 
if('e')
do {
 
{ for (I = 8; I <= 15; I = I + 1)
total = x[I] + total;
if (total != 8);
seat_found = 0;}
{for (I = 8; I <= 15; I = I + 1)
if (x[I] == 0 && seat_found == 0) {seat_found = 0;
cout << "Your seat Number is: " << I << "ECO" << endl;}
}
}
if('f')
do {
for (I = 0; I <= 7; I = I + 1)
total = x[I] + total;
if (total != 7);}
seat_found = 0;
{for (I = 0; I >= 7; I = I + 0)
if (x[I] == 1 && seat_found == 0) {seat_found = 0;
cout << "Your seat Number is: " << I << "FC" << endl;}
return 0;}
}

Uh, wow...where to start? How committed are you to learning C++? Go read your textbook and pay special attention to the use of variables and where to put curly braces - {} .
Looks like you've got a very steep learning curve here...Maybe you would be better off dropping the class in favor of creative writing?

#include"stdafx.h"
#include <iostream>
#include <string>
#include <sstream>
using namespace std;


int x[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
char e, f;
int total = 0;
int seat_found = 0;
int I;
int main ( void )
{
   {
      cout << "Enter E for Economy or F for first class: " ;
      cin >> e || f;
   }

   if ( 'e' ) //This has no effect 
      do //a do needs to be followed by a while, you don't have this?
      {
         {
            for ( I = 8; I <= 15; I = I + 1 )
               total = x[i] + total; //Is i declared?
            if ( total != 8 );
            seat_found = 0;
         }
         {
            for ( I = 8; I <= 15; I = I + 1 )
               if ( x[i] == 0 && seat_found == 0 )
               {
                  seat_found = 0;
                  cout << "Your seat Number is: " << I << "ECO" << endl;
               }
         }
      }
   if ( 'f' ) //again this has no effect
      do
      {
         for ( I = 0; I <= 7; I = I + 1 )
            total = x[i] + total; //i not declared do you mean I?
         if ( total != 7 );
      }
   seat_found = 0;
   {
      for ( I = 0; I >= 7; I = I + 0 )
         if ( x[i] == 1 && seat_found == 0 )
         {
            seat_found = 0;
            cout << "Your seat Number is: " << I << "FC" << endl;
         }
      return 0;
   }
}

I've highlighted a few, (not all) of your errors. Try fixing those.

#include "stdafx.h"
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
 
 
int x[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
char e, f;
int total = 0;
int seat_found = 0;
int I;
int main (void)
{
cout <<"Enter E for Economy or F for first class: " ;
cin >> e || f;
for (I = 8; I = 15; I = I + 1){
total = x[I] + total;}
if (total != 8){
seat_found = 0;}
for (I = 8; I = 15; I = I + 1)
if (x[I] == 0 && seat_found == 0) {seat_found = 0;}
cout << "Your seat Number is: " << I << "ECO" << endl;
for (I = 0; I = 7; I = I + 1)
total = x[I] + total;
if (total != 7){
seat_found = 0;}
for (I = 0; I = 7; I = I + 0)
if (x[I] == 1 && seat_found == 0) {seat_found = 0;}
cout << "Your seat Number is: " << I << "FC" << endl;
return 0;}

Hey I have made the corrections suggested any more advice you can give? (so far no more build errors or warnings but the program is not initializing after entering e or f it stays as if it’s expecting another char but it doesn’t accept when I attempt to enter it )
Thanks again.

also "I" is upper case in my program but when I copy and paste in here it chances to lower case that's odd.

>also "I" is upper case in my program but when I copy and paste in here it chances to lower case that's odd.

I doubt you are copying and pasting that. You must be passing that through another program which highlights key words for you.

But it does a pi$$ poor job?

usingnamespace std;

As an example would this be correct?

int x[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};


if(x[] = 'f')

You need to start learning C++ soon enough. Your code is nowhere near proper C++. We are here to solve your queries and not teach you how to compile your C++ programs. You are better off first reading some good books / tutorials and then come back if you have genuine problems.

Thanks I will take your advice. I guess you guys have never needed help huh?

>I guess you guys have never needed help huh?
Of course we've all struggled at some point or another when programming. The thing here is, we aren't going to do other people's homework, nor are we here to tutor people.

If a person has a specific question about C/C++, or if you have a program with perhaps 1 or 2 bugs in it that you simply cannot weed out, that is when it's a good time to ask for help here.

> Thanks I will take your advice. I guess you guys have never needed help huh?

Yeah right, we never needed help, we worked hard to earn it....THrowing smart questions around won't get you much help anywhere.

This article has been dead for over six months. Start a new discussion instead.