C++ :: Airline Reservation Simulator - Binary File Errors

Aug 11, 2014

For a big project for school I have to make an airline reservation simulator but I have run into a problem. I want to save the the flight code and its location in a binary file so that I can obtain a code according to the location but this happens:

[URL] ... (link to current output and expected output)

Here is the source class

class file {
private:
char code[8];
char from[20];
public:
void input();

[Code] ....

View 4 Replies


ADVERTISEMENT

C++ :: Airline Reservation - Assign Seats On Each Flight

Jun 24, 2013

A small airline has just purchased a computer for its new automated reservation system. you have been asked to program a new system. Develop a program to assign seats on each flight of the airline's only plane (capacity = 10 seats) your program should display the following alternatives

Please type 1 for "SMOKING"
Please type 2 for "Non-Smoking"

if the person types 1, your program should assign a seat in the smoking section (seats 1-5). If a person types 2, your program should assign a seats in the non-smoking section (seats 6-10). your program should then print a boarding pass indicating the person's seat number and whether it is in the smoking or non-smoking section of the plane.

Use a single-subscripted array to represent the seating chart of the plane. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seats is assigned, set the corresponding elements of the array to 1 to indicate that the seat is no longer available.

Your program should never assign a seat that has already been assigned. When the smoking section is full, your program should ask a person if it is acceptable to be placed in the non-smoking area section ( and vice versa ), If yes, make the appropriate a seat assignment. If no, print the message " Next flight leaves in 3 hours! ".

View 5 Replies View Related

C++ :: Airport Reservation Program - Binary Files Comparing

Aug 18, 2014

I am working on a airport reservation program and i have run into a brick wall. i want to ask the user its name, gender, passport no, age, destination, and travel class and figure out the day and flight code of the flight which i have saved in a binary file. now every thing works fine except the code and the day.

The programs important section

the flight class Code:
class flights {
char code[9],location[21];
public:
void display();
char *retloc() //to get the Location

[Code] .....

View 13 Replies View Related

C++ :: Binary Tree Template - Getting Errors / Unresolved External Symbol

Feb 10, 2013

When I compile the program, I get errors I've never seen before. Here's my program:

Header File
#ifndef BINARYTREE_H
#define BINARYTREE_H
#include <iostream>
using namespace std;

[Code] ....

And my errors
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall BinaryTree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::insertNode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)"

[Code] ....

View 2 Replies View Related

C/C++ :: Random Array Filling Of Airline Seating Assignment?

Dec 25, 2014

int firstarray[12][7] = { };
double firstClass(int airplane, int seats, double price)
{cout<<setw(60)<<"---------------------...
cout<<setw(60)<<"You are in **first class** booking screen

[Code] .....

The thing is, The first 2 rows having 7 columns like this:

0000000
0000000

User gives an input of seats reserved, for example user inputs 3 seats, then the program should give output like:

1110000
0000000

I will not ask any specific seat but put assign seats randomly where available.. How to do it?

View 5 Replies View Related

C/C++ :: How To Change Seat Reservation

Jun 9, 2014

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void) {
char answer;//예약 선택
int select1 = 0, select2 = 0, i, j;//필요 변수 선언
int seat[5][5] = { 0 };

[Code] .....

well this is my seat reservation code and my program show the seats like

1 1 2 3 4 5
2 0 0 0 0 0
3 0 0 0 0 0
4 0 0 0 0 0
5 0 0 0 0 0

I want to change these numbers to "■" and "□"(when it's empty seat)

View 1 Replies View Related

C :: Binary File Write By User Input Then Printing Binary File Data Out

Dec 6, 2013

Following is the program I wrote it basically takes 9 inputs and then save them into binary file. then print out the data stored in binary data and find inverse of it then print the inverse out. but its stuck in a loop somewhere.

Code:
#include <stdio.h>
int main() {
int a[3][3],i,j;
float determinant=0;
int x;
FILE *fp = fopen ("file.bin", "wb");

[Code] .....

View 6 Replies View Related

C/C++ :: Train Reservation Program - Declaration Terminated Incorrectly

Dec 8, 2013

//PROGRAM - TRAIN RESERVATION
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
#include<stdio.h>
#include<fstream.h>
#include<process.h>

[Code] .....

View 1 Replies View Related

C++ :: Implementation File Versus Header File - Eclipse Giving Errors

Feb 10, 2013

I have written my program and it works when I keep everything in the header files, and then have my main. I am now splitting them up into implementation files, but Eclipse keeps giving me errors. It gives me error at every opening brace of the constructor and functions. It says on all of them "Redefinition of (name of constructor or method), Previously declared here." What am I doing wrong, because it works in the header file?

#include "KeyValuePair.h"
template<typename Key,typename Value>
KeyValuePair<Key,Value>::KeyValuePair()

[Code] .....

View 3 Replies View Related

C++ :: Class / Header File Related Errors

Sep 22, 2014

Here's my class/header, and Visual studio Output.

Injection point/instantiation.

int main() {
Player player;

Call to a public method:
while(!isWin("x", board) && !isWin("o", board) && whoGoesFirst == "p") {
printBoard(board);
board = player.playerTurn(board);

[Code] .....

Output:
1234
1
1> Player.cpp
1>c:users
sccdocumentsvisual studio 2012projectsprog 2100 - assignment 1prog 2100 - assignment 1player.h(10): error C2143: syntax error : missing ';' before '<'
1>c:users
sccdocumentsvisual studio 2012projectsprog 2100 - assignment 1prog 2100 - assignment 1player.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:users
sccdocumentsvisual studio 2012projectsprog 2100 - assignment 1prog 2100 - assignment 1player.h(10): error C2238: unexpected token(s) preceding ';'

View 2 Replies View Related

C++ :: Bit Shifting - Cache Simulator

Apr 18, 2013

I'm attempting to make a cache simulator in C++. But I need to access individual bits in an integer to figure out where in my "cache" the writing actually gets done. I'm pretty new to bit shifting. Say I'm trying to access the the bits of the int 5, which are its "address". I'm simulating a direct mapped cache. I need to find its tag, the set it goes into, and which line. How do I use bit shifting to access the bits to acquire the tag, the index bits, offset bits, block number...all these pieces in order to actually find where I store it in the cache.

View 6 Replies View Related

C++ :: Gravity Simulator Implementation

Jul 9, 2013

I've been working on creating a simulator to crash two galaxies together as part of a project to stress test a CUDA super computer. I've got a long way to go and am currently just working on correctly simulating n-body gravity functions. First I will use this to simulate the cores of the galaxies (the black holes) and eventually the stars.

So long story short I'm working on the beginnings of a gravity simulator. At this point I found some basic code that works well but doesn't quite give the effect I'm looking for.

The code below only pulls each object towards each other like a spring faster and faster until they shoot off into infinity. I try to give one of my bodies an initial velocity to get it to orbit another, but it always just shoots straight at the other body. I'm thinking I need to factor in inertia so that the initial velocity doesn't just get calculated away really fast by the other calculations.

I'm really looking for a bit of direction to get a real gravity simulator with orbits and such working right so eventually I can scale it up to a galaxy, throw in 100B stars and let the CUDA run for a month..

Code:
void update_galaxies(GLdouble elapsedTime) {
//Calculate gravity simulations
GLdouble r1, r2, r3;
r1 = r2 = r3 = 0.0;

for(unsigned int i = 0; i < galaxies.size(); i++)

[Code] ....

As you can see, I'm calculating all the bodies in a vector called "galaxies" with each other, and doing a basic gravity calculation to it. The update_position function simply takes the calculated acceleration and uses it to calculate the velocity and position based on the "elapsedTime".

I think I need to use the Varlet or Runge-Kutta integration methods, after doing a bit more research.

View 9 Replies View Related

C :: Cache Simulator - Bit Shifting

Apr 21, 2013

I'm attempting to make a cache simulator in C++. But I need to access individual bits in an integer to figure out where in my "cache" the writing actually gets done. I'm pretty new to bit shifting. Say I'm trying to access the the bits of the int 5, which are its "address". I'm simulating a direct mapped cache. I need to find its tag, the set it goes into, and which line. How do I use bit shifting to access the bits to aquire the tag, the index bits, offset bits, block number...all these pieces in order to actually find where I store it in the cache. I need to break the bits up into 3 sections: tag, set index, and block index. I think I can figure out the set and block index sizes based on the values passed in. The tag bits are just the remaining ones. And I'm hard coding values such as cache size (C) - 1024, number of physical address bits (m) - 32, block size (B) - 2, number of lines per set (E) - 1 (again, directly mapped cache). How would this look? I'll be using unsigned longs, so it can handle up to 64 bits.

View 3 Replies View Related

C :: Secure Entry Keypad Simulator

Feb 15, 2015

We've been tasked write a code which would mimic a secure entry keypad.. Only recognising the digits 0-9 for the passcode, and non-numerics S (start again) C (clear last digit) and E (enter) for the control. All other key strokes are to be ignored.

The passcode has to be <10 digits and represented on the screen by "****", with any keystrokes >10 ignored.
The valid passcode being 4 digits (1234).

With 3 attempts to get the correct pass code, after each fail attempt as please try again message show, where after the 3rd attempt a specific message is displayed and an alarm sounds..

View 13 Replies View Related

C++ :: Dice Simulator - Floats Rounding Up

Oct 28, 2013

I made this dice simulator which basically throws the dice 1 million times and outputs the frequency and percentage average for each side (1 to 6).

Everything is working fine, except my averages (floats) seem to be rounding up, causing 4% being "unassigned" at the end of the million rolls. I'm outputting with a setprecision of 2, but I only get 0's and no fractional numbers.

View 5 Replies View Related

C++ :: Creating Space Simulator Program For University

Aug 5, 2014

I'm creating a space simulator program for uni and I've got 3 errors that I just can't seem to fix.

View 10 Replies View Related

C/C++ :: Simulator To Implement Populations For Given Number Of Months?

May 18, 2013

How can i implement a simulator that computes the populations for a given number of months for all sectors.

View 1 Replies View Related

C++ :: Error Handling - Enigma Cipher Simulator

Jan 4, 2014

I finished my Enigma cipher simulator...how should I write the error handling code? Should I throw an exception in main, or in the Enigma ctor and Encrypt() fn when the user enters a non-alphanumeric character?

Rotor.hpp

Code:
#ifndef ROTOR_HPP
#define ROTOR_HPP
class Rotor {
public:
Rotor(char pos='A');
Rotor(const Rotor & rhs);
Rotor& operator=(const Rotor& rhs);

[Code] ....

Output

Code:
Enter rotor settings:
ABCDEFGHIJ
Enter cleartext:
HELLO WORLD
Ciphertext:
0O258 SGY5V

View 3 Replies View Related

C++ :: Battle Simulator - Save / Load Functions Not Working

Oct 16, 2013

I've been working on a battle simulator, and using it as a learning experience. So far, I've been able to debug the program, and learn some stuff, and it's been running smoothly. It's still runnable, but I've been trying to make it so the player can save his character, and continue the game later. However, I'm not sure whether it's the save or load function that's not working, because even if i save to a txt file, it's just a bunch of random characters. I don't know if that means it's not saving correctly, or if it's just supposed to be like that. Anyway, here are the two functions I'm speaking of:

Code:
void Game::saveGame(Character &player) {
std::ofstream saveFile("save.bin", ios::binary);
saveFile.write((char *)&player, sizeof(player));
saveFile.close();

[Code] .....

My program is in multiple files, so I can't really post the whole code easily, but I can upload or something if I really need to.

View 14 Replies View Related

C++ :: Highway Simulator - Cars Move From Start Point To Quit At End

Jun 12, 2013

i want to draw a highway, this simulator must not be graphical (must draw by "|" and "-" and...) . this highway include 3 type of car,

1- heavy
2-light heavy
3-light, t

These cars move from start point to quit at end of highway, highway must be object (programmed by class), and have 200 columns and 4 raw, it must be horizontal... . the cars speed are different,

speed =1,2,3; length=1,2,3;

View 3 Replies View Related

C :: How To Make Text File Of Bits Stored In AVI / Binary File

Feb 5, 2014

I need to create a program which could create text files of the bits stored in avi file/binary file. My first requirement is to show 0s and 1s in the text representation . My second requirement is to create an avi file from this text file. I have tried few codings but either they give me error or they not playing the reconverted binary files.

View 6 Replies View Related

C++ :: Read From Txt File One Bit At A Time And Then Write Into Binary File

Apr 22, 2013

I am trying to get the code to read from the txt file one bite at a time and then write this bite into the binary file but i cant seem to get it working.

FILE *fpcust, *fpcustbin; //<<<<<-----point to both sales and customers text files, and the new .bin files for both
char buffer;
int ch;
int ch1;
fpcust = fopen("c:customers.txt", "r"); //<<<<-----pointing to the file
fpcustbin = fopen("c:customers.bin", "wb"); //<<<<<-----pointing to the new binary file, opening in writing binary

[Code]...

View 3 Replies View Related

C++ :: Convert Text File Containing 0 And 1 To Binary File

Apr 15, 2014

I just wrote a program for Huffman Encoding, where I take a text file, encode it in the form of 0's and 1's, and save that as another text file. However, this does not solve my purpose as it is taking even more space.

So I want to know how do I convert a text file containing these 0'S & 1's to a binary format.

Here is my program:

#include <stdio.h>
#include <string.h>
#include<fstream>
#include<string>
#include<iostream>
using namespace std;
typedef struct node_t {
struct node_t *left, *right;
int freq;
char c;

[Code]...

View 1 Replies View Related

C++ :: Text File To Binary File

Sep 14, 2013

I want to convert a text file into binary file. I should create the text file by myself. I also use a structure for the components:

struct Data
{
int num;
char name[30];
};

I write information in the text file like this:

Data d;
cin >> d.num >> d.name;
fstream file("Name.txt");
file << d.num << d.name << '
';

If I have entered:
3 Steve
is easy to get this data. I just make another variables and get the data in them:

int num2;
char name2[30];
file >> num2 >> name2;

And everything is done. But what if I have this:

cin >> d.num;
cin.getline(d.name, 100);
file << d.num << d.name;

and the input is:
5 Steve Brown

I can get the number easy like before but how can I get the whole name? If I use:

int num2;
file >> num2;
char a[30];
file >> a;

I get only the first name "Steve". Can I get somehow and the second name in the same variable?

View 12 Replies View Related

C++ :: How To Read Binary Img File

Nov 24, 2014

When reading a binary .img why is it when you read it by slurping in the file, then save it to a string and cout, you don't see the binary but random garbage?

View 11 Replies View Related

C :: Is There Way To See Binary Content Of File

Apr 3, 2013

I am using c to read and write contents of a file into other:

FILE *ptr;
status_t status;
uint32_t block_size, result;
uint32_t num_blocks;
char temp_buffer[1024];
}

[code]....

Is there way to see the binary content of this file.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved