473,692 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

working with arrays, creating a video library

i LOVE doing c++ programming, but i never can get myself started! Once i
figure it out, its fun but anyways here it goes...
Im given a file c:\temp\hwk8inp ut.txt, which contains the records of the
video collection of a small local library.
There are four fields for each video:
1) A unique video ID number without space (v1, v2, etc.);
2) The full video title;
3) The availability of the video (0 for checked out and 1 for checked
in);
4) A unique borrower ID without space (c0001, c0009, etc.) if the video is
checked out, otherwise blank.
Write code to read these data into your program, the display the following
menu to the user:
What do you want to do?
1. List all the videos
2. Check out a video
3. Exit the system

If you choose option one, videos displayed like this
Video ID: v1
Title: Godfather, The (1972)
Status: Checked out by c0001
......
And return to the menu.
If the user chooses option 2, ask for the video ID first
1) If the video ID is not valid, tell the user so and return to the menu.

2) If the video is checked in, ask for the borrower ID, then update the
status to be checked out and the borrower ID with the user input. Return
to the menu after processing.
3) If the video is already checked out, tell the user so and return to the
menu.
When the user chooses option 3, save the data back to the original input
file in the same format and terminate the program.
Your program should repeat the above until the user chooses to exit.

the following starting coade was already given to me
#include<iostre am>
#include<fstrea m>
#include<string >
using namespace std;
int readData(string id[], string title[], string available[], string
who[]);

void saveData(const string id[], const string title[], const string
available[], const string who[], int count);

void displayAll(cons t string id[], const string title[], const string
available[], const string who[], int count);

int search(const string arr[], string what, int count);

void checkout(const string id[], const string title[], string available[],
string who[], int count);

int showMenu();

int main() {
string vID[50], vTitle[50], checkedIn[50], bID[50];

//read data from the input files and get the number of videos returned
int nbrVideos = readData(vID, vTitle, checkedIn, bID);

int choice;
do{
choice = showMenu();
if(choice == 1)
displayAll(vID, vTitle, checkedIn, bID, nbrVideos);
else if(choice == 2)
checkout(vID, vTitle, checkedIn, bID, nbrVideos);
}while(choice != 3);

saveData(vID, vTitle, checkedIn, bID, nbrVideos);

return 0;


sorry this is so long, but hopefully anyone can help, id appreciate it.
Thanks in advance! :-)

Nov 14 '06 #1
3 2064

triplejump24 wrote in message ...
>
the following starting coade was already given to me
<snip program outline>
>
sorry this is so long, but hopefully anyone can help, id appreciate it.
Thanks in advance! :-)
Glad to help....
>int main(){
string vID[50], vTitle[50], checkedIn[50], bID[50];
//read data from the input files and get the number of videos returned
int nbrVideos = readData(vID, vTitle, checkedIn, bID);
int choice;
do{
choice = showMenu();
if(choice == 1)
displayAll(vID, vTitle, checkedIn, bID, nbrVideos);
else if(choice == 2)
checkout(vID, vTitle, checkedIn, bID, nbrVideos);
} while(choice != 3);
saveData(vID, vTitle, checkedIn, bID, nbrVideos);
return 0;
// Here is your first big problem. 'main()' needs a closing brace.
} // main() end
Now you will probably want to do the next step and write the body
(definition) for this:

int readData(string id[], string title[], string available[], string
who[]);

--
Bob R
POVrookie
Nov 14 '06 #2

triplejump24 wrote:
i LOVE doing c++ programming, but i never can get myself started! Once i
figure it out, its fun but anyways here it goes...
Im given a file c:\temp\hwk8inp ut.txt, which contains the records of the
video collection of a small local library.
There are four fields for each video:
1) A unique video ID number without space (v1, v2, etc.);
2) The full video title;
3) The availability of the video (0 for checked out and 1 for checked
in);
4) A unique borrower ID without space (c0001, c0009, etc.) if the video is
checked out, otherwise blank.
So write a class that represents a "video" record. That way each video
is a given type and you won't have to keep one container of IDs,
another container of titles, etc.

Your collection is a container of videos. Very simple.
Write code to read these data into your program, the display the following
menu to the user:
What do you want to do?
1. List all the videos
2. Check out a video
3. Exit the system
Thats useless, get the video storage system to work first.
>
If you choose option one, videos displayed like this
Video ID: v1
Title: Godfather, The (1972)
Status: Checked out by c0001
.....
And return to the menu.
If the user chooses option 2, ask for the video ID first
1) If the video ID is not valid, tell the user so and return to the menu.

2) If the video is checked in, ask for the borrower ID, then update the
status to be checked out and the borrower ID with the user input. Return
to the menu after processing.
3) If the video is already checked out, tell the user so and return to the
menu.
When the user chooses option 3, save the data back to the original input
file in the same format and terminate the program.
Your program should repeat the above until the user chooses to exit.

the following starting coade was already given to me
Well, sorry to hear that. What follows is exactly how *not* to do it.
>
#include<iostre am>
#include<fstrea m>
#include<string >
using namespace std;
int readData(string id[], string title[], string available[], string
who[]);

void saveData(const string id[], const string title[], const string
available[], const string who[], int count);

void displayAll(cons t string id[], const string title[], const string
available[], const string who[], int count);

int search(const string arr[], string what, int count);

void checkout(const string id[], const string title[], string available[],
string who[], int count);

int showMenu();

int main() {
string vID[50], vTitle[50], checkedIn[50], bID[50];

//read data from the input files and get the number of videos returned
int nbrVideos = readData(vID, vTitle, checkedIn, bID);

int choice;
do{
choice = showMenu();
if(choice == 1)
displayAll(vID, vTitle, checkedIn, bID, nbrVideos);
else if(choice == 2)
checkout(vID, vTitle, checkedIn, bID, nbrVideos);
}while(choice != 3);

saveData(vID, vTitle, checkedIn, bID, nbrVideos);

return 0;

sorry this is so long, but hopefully anyone can help, id appreciate it.
Thanks in advance! :-)
Look at it this way, if i needed to store 10 people's names in a
container with their first name, last name, sex and age, i'ld do as
shown below. Why? Because the exact same code works whether i make 10
or one billion people. And frankly, if i can't store people, i couldn't
care less about some menu.

#include <iostream>
#include <string>
#include <vector>
#include <iterator>

class Person
{
int age;
bool sex;
std::string firstname;
std::string lastname;
public:
Person();
Person(int, bool,
const std::string&, const std::string&);
friend std::ostream&
operator<<(std: :ostream&, const Person&);
};

Person::Person( )
: age(0), sex(true),
firstname(""), lastname("")
{
}

Person::Person( int n, bool x, const std::string& fn,
const std::string& ln)
: age(n), sex(x),
firstname(fn), lastname(ln)
{
}

std::ostream&
operator<<(std: :ostream& os, const Person& r_p)
{
std::cout << "name: " << r_p.firstname;
std::cout << " " << r_p.lastname;
std::cout << "\tsex = " << std::boolalpha << r_p.sex;
std::cout << "\tage = " << r_p.age;
return os << std::endl;
}

int main()
{
Person person(25, true, "Mary", "Smith");
std::vector< Person people(10, person); // 10 people

std::copy( people.begin(),
people.end(),
std::ostream_it erator< Person >(std::cout)) ;
}

/*
name: Mary Smith sex = true age = 25
name: Mary Smith sex = true age = 25
name: Mary Smith sex = true age = 25
name: Mary Smith sex = true age = 25
name: Mary Smith sex = true age = 25
name: Mary Smith sex = true age = 25
name: Mary Smith sex = true age = 25
name: Mary Smith sex = true age = 25
name: Mary Smith sex = true age = 25
name: Mary Smith sex = true age = 25
*/

Nov 14 '06 #3

"triplejump 24" <lo********@yah oo.comwrote in message
news:70******** *************** *******@localho st.talkaboutpro gramming.com...
>i LOVE doing c++ programming, but i never can get myself started! Once i
figure it out, its fun but anyways here it goes...
Im given a file c:\temp\hwk8inp ut.txt, which contains the records of the
video collection of a small local library.
....
the following starting coade was already given to me
This is obviously your homework. It's up to you to do your own work. If
you need help with something specific, post the code you're having a problem
with and tell us what help you need with that code (such as "Why does this
line gives me such-and-such an error?"), and we'll be glad to help. We're
not going to simply do your homework for you, though.

-Howard
Nov 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4104
by: Ashot | last post by:
Hi, I need to write a video analysis tool which extracts statistics from microsocope video. Essentially what I need is to translate the video data into numerical matrices. I have been using Python for the past 1.5 years anytime I could for absolutely everything, because it has every library imaginable... Alas, I can not find a library for decoding video/using codecs. The only solution I have been able to come up with is to create an...
7
11773
by: csx | last post by:
Hi everyone! two quick questions relating to arrays. Q1, Is it possible to re-assign array elements? int array = {{2,4}, {4,5}}; array = {2,3}
5
5457
by: jen_designs | last post by:
How do I create custom controls for an embeded video. I need stop, play, pause, etc. Any thoughts?
3
3788
by: Mark | last post by:
Hi From what I understand, you can pass arrays from classic ASP to .NET using interop, but you have to change the type of the.NET parameter to object. This seems to be because classic ASP passes a variant containing an array, and interop expects a parameter of type object if you are passing a variant (you are expected to cast it to the correct type in your code). I'd like to find a way of passing arrays so that you don't need to change...
6
2622
by: Jerry Spence1 | last post by:
Why doesn't the following work in my ASP program? I have imported ADOX I am trying to create a temporary database on the user's PC. The example is taken from Microsoft. Dim cat As Catalog = New Catalog cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\NewMDB.mdb;" & _
2
2250
by: John | last post by:
Hello everyone, I'm currently writing a program to keep track of schedule changes at a school. The goal is to have someone using the program to declare changes, then the program writes a html file, which is uploaded to a webserver. Then students and teachers can view it online, but there are also a couple of computers with 19" monitors standing around the school to display the webpage (IE kiosk mode). The program has a form containing...
17
3246
by: I.M. !Knuth | last post by:
Hi. I'm more-or-less a C newbie. I thought I had pointers under control until I started goofing around with this: ================================================================================ /* A function that returns a pointer-of-arrays to the calling function. */ #include <stdio.h> int *pfunc(void);
3
2018
by: pbd22 | last post by:
hi. i thought there would be volumes on this topinc on the internet, but i am having a tough time finding what i am looking for. i am trying to learn how to move a video from a cam corder or some device to the PC and then upload it to my web site, storing it on the server. i am looking for: 1. an explaination as to which destination is better - BLOB in SQL or
8
2363
by: RobcPettit | last post by:
Hi, What is the best way to use an array to find moving averages. I want to calculate a 15 day and 41 day m/a. I know my array will need to contain 12 columns, but the rows need to be dynamic. The row size will need to be aminium of 50 rows. So far Im thinking of either creating 2 arrays, one for 15 and one for 41 day m/a. Keeping them each to that row size then iterate through them creating new arrays when new data added. Eg when 16 data...
0
8603
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8797
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8800
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6459
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4323
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4557
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2237
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1957
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.