How come my code is not doing what I want it to do....
Here is my code.....
CODE
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
// Global variables
const int Number_Rows = 5; // Number of Rows.
const int Number_Columns = 10; // Number of Columns.
// Declarations for your functions
void showSeatsChart(float[][Number_Columns]);
void availableSeatsByRow(int, float[][Number_Columns]);
void availableSeats(float[][Number_Columns]);
void getCountOfSoldSeats(float[][Number_Columns]);
void main()
{
float Prices[] = {100.00,75.00,50.00,25.00,5.00};
// Prices by Row
float Price[Number_Rows];
float Seats[Number_Rows][Number_Columns]; // Seats Array.
int i;
// Initialize your array here so it will be ready to go for all functions.
for(int j = 0; j < Number_Rows; j++)
{
for(int k = 0; k < Number_Columns; k++)
{
//if(Seats[j][k] = 0.00)
}
}
// Ask for price for seat, input price.
for(i = 0; i < Number_Rows; i++)
{
cout << "Please enter the rate for seats in row " << (i + 1) << endl;
cin >> Prices[i];
}
// Selling a Seat.
cout << "No seats sold yet." << endl;
showSeatsChart(Seats);
// Let's sell one seat in row 3
cout << "Sold one seat in row 3!" << endl;
Seats[2][0] = 34.00;
showSeatsChart(Seats);
}
// Seating Chart
void showSeatsChart(float Seats[][Number_Columns])
{
// Loop through the rows and columns.
for(int y=0;y<Number_Rows;y++)
{
for(int x = 0; x < Number_Columns; x++)
{
if(Seats[y][x]==0.00)
{
cout<<"#";
}
else{
cout<<"*";
}
}
cout<<endl;
}
cout<<endl;
}
// Function to return how many seats are available in a given row.
void availableSeatsByRow(int row, float Seats[][Number_Columns])
{
string output; // Temp string variable.
int i=0; // Temp counter.
for(int x=0;x<Number_Columns;x++)
{
if(Seats[row][x]==0.00)
{
i++;
output+=""+(x + 1);
}
if(i)
{
cout <<"The followingseats are available in row "<<(row +
1)<<":"<<output<<endl;
}
else {
cout<<"There are no seats available in row "<<(row + 1)<< ":"<<endl;
}
}
}
// A function to give all the seats available in the entire auditorium.
void availableSeats(float Seats[][Number_Columns])
{
string output; // Temp variable string.
int i;
for(int y=0;y <Number_Rows;y++)
{
i =0;
output="";
for(int x=0;x<Number_Columns;x++)
{
if(Seats[y][x]==0.00)
{
i++;
output+=""+(x + 1);
}
if(i)
{
cout<<"The following seats are available in row"<<(y + 1)<<
":"<< output<<endl;
}
else{
cout<<"There are no seats available in row"<<(y + 1)<<":"<<endl;
}
}
}
}
// How many seats have been sold.
void getCountOfSoldSeats(float Seats[][Number_Columns])
{
int output=0; // Output Variable;
for (int y =0; y< Number_Rows;y++)
{
for (int x= 0;x<Number_Columns;x++)
{
if(Seats[y][x]!=0.00)
{
output++;
}
}
}
cout << "The total number of tickets sold is $" << output << endl;
}
This is what im suppoust to do....
Write a program that can be used by a small theature to sell tickets for performances. the theatures auditorium has 5 rows and 10 columns. the program should display a screen that shows which seats are available and which are taken. Seats that are taken are represented by an * symbol, seats that are available are represented by an # symbol.... it should look similar to this one...
Seats
1 2 3 4 5 6 7 8 9 10
Row 1:
Row 2:
Row 3:
Row 4:
Row 5:
When the program begins, it should ask the user to enter the seat prices for each row. the prices can be stored in a seperate array.
once the prices are entered, the progrma should disply a seating chart similar to the one shown above. the uses may enter the row and seat numbers for tickets being sold. everythime a ticket or group of tickets is purchased, the program should display the total ticket prices and update the seating chart.
the program should keep a total of all ticket sales. the user should be given an option of viewing this amount.
the program should also give the user an option to see a list of how many seats have been sold, how many seats are available in each row, and how many seats are available in the entire auditorium...
if someone can please show me why program is not doing what its suppoust to... thank you...