C++ :: can't Get Program To Print Only Available Seats
May 1, 2014
I can't get my program to print only AVAILABLE SEATS; instead it prints Both Available and Taken.
//Program allows you to delete and add seats to the Airplane. Also to upload seat settings as a text file.
#include <iostream>
#include <fstream> //file stream for text file
#include <string>
using namespace std;
[code].....
View 6 Replies
ADVERTISEMENT
Apr 26, 2014
I am supposed to create a program that assigns passenger seats in an airplane. First I am suppose to generate an array with random X's. Then I am supposed to ask the user to pick a seat. From there I am supposed to check if the seat is already taken. My problem is when I ask them to pick a seat it generates an array of nothing but X's. Also how would I allow the program to accept the seat numbers as either uppercase or lowercase letters. for example if they want seat '3C' how would I allow them to enter the C as either a lower case or upper case.
//Oscar Lopez
#include <iostream>
#include <cmath>
[Code].....
View 2 Replies
View Related
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
May 2, 2014
The assignment is to read in a text file of passenger names (first and last initial), seats (A1, B1, C1, D1, A2, etc.), and ticket prices. The output is specified to be a table of passengers and their seats sorted by seat order, and I also have to print the minimum and maximum ticket prices along with the owner of each ticket, along with the average of all ticket prices. My arrays are all reading in correctly, and the minimum, maximum, and average ticket prices were all easy to find. My problem is the sorting.
We were introduced to arrays a couple weeks ago and this is our first time doing any sorting. We are supposed to use a bubble sort, and while I think I gather how to use a bubble sort, it's not working in my program (so obviously I don't really know how to use it). I have tried several different things, and sometimes a few seats/names will switch around (never the way I want them to) and sometimes nothing will happen at all.
New to programming, not trying to get homework done for me, need to bubble sort airplane passengers and seats by seat order (A1, B1, C1, D1, A2, etc).
My input looks like this:
A Z A1 555.55
repeat with different initials, seats, and prices however many times the user sees fit.
I have a 1D character array for the columns(A - D), a 1D integer array for rows (1 to maximum integer), 1D float array for prices, and 2D array for name initals.
Here's the function to read in the arrays:
void read_Arrays(char seat_cols[], int seat_rows[], char name[][LAST], float price[]) {
int i, j;
for(i = 0; i < FIRST; i++) {
for(j = 0; j < LAST; j++) {
scanf(" %c", &name[i][j]);
} scanf(" %c %d %f ", &seat_cols[i], &seat_rows[i], &price[i]);
}
}
Here's the sort. The way we were shown to do it was with a 'for' loop nested within a 'do while':
{
do {
flag = 0;
for(i=0; i < ROWSIZE-1; i++) {
if(seat_rows[i] > seat_rows[i + 1]) {
[code]....
View 6 Replies
View Related
Nov 28, 2013
I need help writing a program where I use small letter to write names in Big letters. (I dont know if you understand what i mean). Follow link to description.
[URL]
View 6 Replies
View Related
Apr 14, 2013
I am writing a program that prints the sum of even and odd numbers and here is my code
#include <iostream>
using namespace std;
const int SENTINEL = -999;
int main() {
int integers = 0;
int even = 0;
int odd = 0;
[Code] ....
Nut now in the output it adds -999 to the odd numbers ....
View 3 Replies
View Related
Oct 20, 2013
Well what the title says, but I can't get it done. This is what I got
Code:
#include <stdio.h>#include <string.h>
int main(void)
{
char word;
int count;
printf("Enter a word.
[Code] ....
View 4 Replies
View Related
Feb 11, 2014
I have to develop script in C to print the alphabets in given notation.
Please check the attachment.
View 4 Replies
View Related
Mar 16, 2014
i have to make two functions one recursion that ask the user to enter number of rows and i use recursion to tell him how many pins there are ex. user enters 5 there are 15 pins. I did this function now i need a function that prints an asterisk triangle for my recursion function so for 15 it should look like this
*
* *
* * *
* * * *
* * * * *
i tried many times but can't make it descend like that i can only get like a right triangle..the hard part is that it goes with the users number so if they enter 3 for example it should be 3 rows.
int pins(int n){
if(n==0){
return 0;
[code]....
View 1 Replies
View Related
Jan 16, 2013
I use the AS/400 warehouse system, and I need to be able to automate typing one letter in several different locations to speed things up.
My thoughts are:
1. Find out how to make a program that will determine x, y coordinates of mouseclicks, and then use software to use macros to change information.
2. Build a program that will complete a single process by repeating set mouse clicks and keystrokes.
We recieve HUGE transfers from a warehouse across the country, and have to change the first character of the name of bin locations - and after a few pages it gets VERY tedious.
View 4 Replies
View Related
Feb 10, 2014
The program must print out 5 random numbers, from 1 to 45 and 100 different sequence.. Now I want each number of sequence to be different and not the same....
for example
1,2,3,4,5
6,7,8,9,10
....
...
..
here is my code:
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main () {
int xRan1;
[Code] ....
View 2 Replies
View Related
Nov 24, 2014
I'm trying to make a program in C where the user enters a string and it prints a word for example (name) in lowercase then the same word again but in capitals and lowercase like this (NnAaMmEe).
my code is below;
#include<stdio.h>
#include<ctype.h>
int main()
[Code].....
View 1 Replies
View Related
Sep 22, 2013
Write a program to print out the binary value of a 16 bit number.
Create integers i, count, and mask.
Set 'i' to a hex value of 0x1b53.
Set mask to a value of 0x8000. Why?
print a line to show the hex value of i and then the leader for the binary value like this: Hex value = 1b53 Binary=
Use a for loop to loop 16 times and print 16 digits, using count as the loop counter
To test for each digit value, bitwise and 'i' with 'mask'
when the result for the bitwise and is true, print the number '1'
when the result for the bitwise and is false, print the number '0'
then shift mask one place to the right
print a new line and then quit
Use prtscrn and make a hard copy of the code with the console output.
Extra: use the modulus of count and print a space after every 4th digit to make the binary easier to read
The output should look like this: Hex value = 1b53, Binary= 0001 1011 0101 0011
so far this is what i have
#include <stdio.h>
#include <stdlib.h>
int main() {
int i, count, mask;
// 1B53 0001 1011 0101 0011
// 8000 1000 0000 0000 0000
i = 0x1b53;
[Code] ....
it is telling me that there is an "else" without previous "if", also is the program that I wrote correct?
View 3 Replies
View Related
May 29, 2013
I'm trying to write a program that prints all of the prime numbers to the screen. I'm getting angry because it only prints EVERY number. I think it has something to do with the bool change not being able to leave the for-loop but how to fix it.
Code:
#import <stdio.h>
#include <stdbool.h>
int main(void){
printf("
The Primes Are: 1");
[Code] ....
View 3 Replies
View Related
May 7, 2014
I created a basic socket server, which listensing for incoming udp data. When I run the netcat program, I get a response:
Code:
$ nc -luv 1732
Connection from 10.50.11.12 port 1732 [udp/*] accepted
(?@??8?? ??.?n?5
(?@??8?? ??.?n?5|?>)
(?@??8?? ??.?n?5|?>)
^C |?>)
But with my c program it doesn't give the response. It should say something like "here is the message: " and then give a message.
Code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
[Code] .....
View 2 Replies
View Related
Oct 26, 2013
I want to make a simple program that will print out the factors of an integer. My program right now only outputs "The prime factors of 221 are 221, 221, 221, 221"... Where it should be "The prime factors of 221 are 1, 13, 17, 221"
#include <cstdio>
int factorsOf(int x);
//function
int main() {
int x = 221;
printf("The factors of 221 are ");
[Code]...
View 3 Replies
View Related
Jul 27, 2014
This program prints out the total number of up to 100,000. How to do is to print out the number of twin primes up to 100,000. Is it as simple as adding an if statement "if(primesList[j] - i == 2)"?
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main() {
int primesCount = 0;
[Code] ......
View 4 Replies
View Related
Jan 3, 2015
This is a program to print upper half of the matrix.
#include <iostream>
using namespace std;
int upperhalf(int n, int apu[n][n]) {
cout<<"The upper half of the matrix is :
[Code] ....
the compiler is giving these errors:-
sh-4.2# g++ -o main *.cpp
main.cpp:4:31: error: use of parameter outside fun
ction body before ']' token
int upperhalf(int n, int apu[n][n])
[Code] ....
I dont know where i am wrong.
View 3 Replies
View Related
Sep 12, 2014
I found this implementation on a website for printing the longest common subsequence. But it gives wrong answers for some reason even though the code seems right to me.
Here is the code:
#include <iostream>
int lcs(char *X, char *Y, int m, int n)
{
int L[m+1][n+1];
for(int i = 0; i<=m; i++)
[code].....
What is wrong with this code?
View 7 Replies
View Related
Oct 5, 2014
I am trying to write a program that will make a pattern of stars. The last line is really tripping me up. I have to make the code only using the printf("*"); printf(" "); printf("/n"); statements once. I want to accomplish this with a for loops and if statements.
It is supposed to look like this:
* - 5 spaces before *
* * - 4 spaces before *
* * * - 3 spaces before *
* * * * * * - 0 spaces before *
This is what I've tried so far:
main()
{
int i, j, k;
i=1;
j=1;
[Code]....
here are the links on codepad [URL]
I think my first approach is way off. But I think I am on to something in the second link. I'm trying to print the "*" and extra 2 times on the fourth line. In the second link the compiler appears to be ignoring the || operator. Is my syntax incorrect in the second attempt? How should I change my if statement to make this pattern work?
View 2 Replies
View Related
Aug 23, 2013
Code for the following.
How to print alternate records from a file using fseek?
View 5 Replies
View Related
Apr 4, 2013
I'm required to write a program to print out all booms allowed requests below:
1. User will enter the address of the cell and its value.
2. Print out all booms.
How to solve it by using recursion.
View 4 Replies
View Related
Oct 10, 2014
Why this program won't correctly print the proper totals on screen? See my code and the included screenshot.
Code:
#include <stdio.h>
int main(void) {
int total, first, second;
printf("Enter 2 numbers:
[Code] .....
View 4 Replies
View Related
Feb 20, 2013
How to make it so an output for a program would print out the string in reverse/backwards? I was just curious on how to do this.
View 6 Replies
View Related
Feb 18, 2013
The problem is with the first "Type and Run," where the code looks like this:
Code:
/* print_it.c--This program prints a listing with line numbers! */
#include <stdlib.h>
#include <stdio.h>
void do_heading(char *filename);
int line = 0, page = 0;
[Code] ....
I am using the gcc compiler in Ubuntu 12.04 LTS and I get the following error:
Code:
print_it.c: In function "main":
print_it.c:36:15: error: "stdprn" undeclared (first use in this function)
print_it.c:36:15: note: each undeclared identifier is reported only once for each function it appears in
print_it.c: In function "do_heading":
print_it.c:49:16: error: "stdprn" undeclared (first use in this function)
I was told that "stdprn" can be recognised by a DOS based compiler and the book says I can try using "stdout" instead. It looks like this now:
Code:
/* print_it.c--This program prints a listing with line numbers! */
#include <stdlib.h>
#include <stdio.h>
void do_heading(char *filename);
int line = 0, page = 0;
[Code] .....
It compiled OK with the gcc compiler but I only get this when I run the program:
Code:
Proper Usage is:
print_it filename.ext
I am not sure whether I should continue looking into this but even when I tried compiling and running it on Windows, the .exe file won't even launch. The other ones do but this first one doesn't.
Questions:
1. What should be done to make this program run?
2. Even though the book says "don't care" if the reader does not understand the items (It's Day 1/Lesson 1), I would still like it to run as I don't want to experience compiling and running problems in the future. Should I even bother doing this section of the book or is it obsolete and should be skipped?
View 6 Replies
View Related
Oct 17, 2013
Community Hospital needs a program to compute and print a billing statement for each patient. Charges for each day are as follows:
a. room charges: private (P) room = $125.00; semi-private (S) room = $95.00; or ward (W) = $75.00
b. telephone charge = $1.75
c. television charge = $3.50
Write a program to get data from the keyboard, compute the patient’s bill, and print an appropriate statement. Typical input (nut yours do not have to be identical to this) is the following:
How many days was the room occupied? 5
What type of room? P
Telephone used during the stay? N
Television used during the stay? Y
Keep in mind that the user needs to know that the input can be any integer number of days for the length of stay, either (P, S, or W) for the room type, and either (Y or N) for both telephone and television options.
A statement (which yours MUST be identical to) for the data given follows:
Community Hospital Patient Billing Statement
Number of days in hospital: 5
Type of room: Private
Room charge:$ 625.00
Telephone charge:$ 0.00
Television charge:$ 17.50
TOTAL DUE = $642.50
View 3 Replies
View Related