Archive

Posts Tagged ‘the first line’

Simple Binary Tree Inventory

August 12th, 2009 Comments off

You are to write a program that creates and maintains a binary search tree of items in a super market. Each item has a name and a value. All item names will be lowercase alphabetic strings of less than 30 letters. All values will be positive real numbers representing prices. Also, for each node in the tree, you are to maintain the value of all of the items in that subtree. Your tree should be “sorted” based on alphabetical ordering of the item names as determined by strcmp. Your program must allow the user to do the following:

1) Add an item to the inventory
2) Delete an item from the inventory
3) Print out all of the items in the inventory in alphabetical order.
4) Print out the value of all items underneath the subtree of a given item.

For example, if the user adds these items:

a) “soap”, $2.95
b) “raisins”, $2.00
c) “jellybeans”, $5.00
d) “tea”, $1.95

Input File Specification (inventory.txt)
The first line of the input file will contain a single positive integer, n, representing the number of commands to execute. The following n lines will contain one command each, in the other they are to be executed.

The first number of each of these lines will be either 1, 2, 3 or 4, to signify the choices listed above.

If the choice is 1, it will be followed by the name of the item added and its price (as a number), both separated by spaces.

If the choice is 2, it will be followed by the name of the item to be deleted.

Choice 3 will be on a line by itself.

Choice 4 will be followed by a single string storing an item.

Output Specification
For each command, your program should provide some output.
The output provided by each command should be separated by a blank line.

For choice 1, if the item to be added is NOT in the tree, output a line with the following format:

item has been added to the stock.

where item is the name of the item added. If the item is ALREADY in the tree, output a line with the following format:

Sorry, item is already in stock. No changes made.

For choice 2, if the item to be deleted is IN the tree and is successfully deleted, output a line with the following format:

item has been deleted from the stock.

If the item is NOT in the tree, then output a line with the following format:

Sorry, item couldn’t be deleted because it’s not in stock.

For choice 3, the first line should read:

Here is a list of the items in stock:

Each following line should have information about one item and the list should be in alphabetical order by item name. Here is the format for one of these lines:

item $price

The price should be printed out to two decimal places exactly.

Finally, for choice 4, print out the sum of the values of all the items in the subtree rooted by the designated item. If this item is NOT in the tree, $0.00 should be printed out. Here is the format for the output for this option.

The value of all the items underneath item is $price.

Implementation Restrictions
You must store the data in nodes of a binary tree. Each binary tree node must store 3 pieces of information: the name of the item, its price, and the sum of the prices of all the items in its subtree.

Sample Input File
11
2 soap
1 soap 2.95
1 raisins 2.00
1 jellybeans 5.00
1 tea 1.95
4 raisins
3
2 raisins
4 soap
4 cereal
1 soap 3.50

Sample Output
Sorry, soap couldn’t be deleted because it’s not in stock.

soap has been added to the stock.

raisins has been added to the stock.

jellybeans has been added to the stock.

tea has been added to the stock.

The value of all the items underneath raisins is $7.00.

Here is a list of the items in stock:
jellybeans $5.00
raisins $2.00
soap $2.95
tea $1.95

raisins has been deleted from the stock.

The value of all the items underneath soap is $9.90.

The value of all the items underneath cereal is $0.00.

Sorry, soap is already in stock. No changes made.

CAN I HAVE BEFOR AUGUST 15,2009
THANKS

Create .txt File From Folder

July 25th, 2009 Comments off

I need a perl script to ‘look’ at a directory on a linux server and create a ‘tab’ or ‘pipe’ delimited file with the file names in it as well as the directory names.

an example would be a ‘Images’ folder has 3 directories in it
Images>France>
Images>Grand Canyon>
Images>Wildlife>

and each of these folders has a varied number of .jpg image files in it

I need the script to create a .txt file with 4 sets of item data per line. an ‘ID’ & The ‘name of the sub directory’ & ‘name of the image’ & name of the ‘image without the .jpg extention’

The first line of the text file must always be
ID|Directory|ImageFile|ImageName

*********************************************
example….

ID|Directory|ImageFile|ImageName
1|France|img1.jpg|img1
2|France|image2.jpg|image2
3|France|image3.jpg|image3
4|Grand Canyon|hd98.jpg|hd98
5|Grand Canyon|he729.jpg|he729
6|Wildlife|bear.jpg|bear
7|Wildlife|wolf.jpg|wolf

*********************************************************

this script will be manually run (from a browser) whenever the folder directory is updated via FTP and will overwrite (not append) the previous .txt file with the current image & sub folder structure from the main directory.

The script will need to have a few set variables…. (in the script with a text editor, not when the script is run from the browser)

1. location of the text file. 90% of the time it will be in the same directory as the script but it will be nice to have the ability to have it elswere.
2. location of the main image folder
3. name of the .txt file
4. ability to change the names of the first line. ID|Directory|ImageFile|ImageName

I would like to use perl…. but am open to something else.

Binary Search Tree

July 23rd, 2009 Comments off

(Need by Friday 10pm if possible)

The Problem
You are to write a program that creates and maintains a binary search tree of items in a super market. Each item has a name and a value. All item names will be lowercase alphabetic strings of less than 30 letters. All values will be positive real numbers representing prices. Also, for each node in the tree, you are to maintain the value of all of the items in that subtree. Your tree should be “sorted” based on alphabetical ordering of the item names as determined by strcmp. Your program must allow the user to do the following:

1) Add an item to the inventory
2) Delete an item from the inventory
3) Print out all of the items in the inventory in alphabetical order.
4) Print out the value of all items underneath the subtree of a given item.

For example, if the user adds these items:

a) “soap”, $2.95
b) “raisins”, $2.00
c) “jellybeans”, $5.00
d) “tea”, $1.95

in this order, then the structure of the binary tree would be as follows:

soap 2.95
total: 11.90
/
raisins 2.00 tea 1.95
total: 7.00 total 1.95
/
jellybeans 5.00
total: 5.00

Input File Specification (inventory.txt)
The first line of the input file will contain a single positive integer, n, representing the number of commands to execute. The following n lines will contain one command each, in the other they are to be executed.

The first number of each of these lines will be either 1, 2, 3 or 4, to signify the choices listed above.

If the choice is 1, it will be followed by the name of the item added and its price (as a number), both separated by spaces.

If the choice is 2, it will be followed by the name of the item to be deleted.

Choice 3 will be on a line by itself.

Choice 4 will be followed by a single string storing an item.

Output Specification
For each command, your program should provide some output.
The output provided by each command should be separated by a blank line.

For choice 1, if the item to be added is NOT in the tree, output a line with the following format:

item has been added to the stock.

where item is the name of the item added. If the item is ALREADY in the tree, output a line with the following format:

Sorry, item is already in stock. No changes made.

For choice 2, if the item to be deleted is IN the tree and is successfully deleted, output a line with the following format:

item has been deleted from the stock.

If the item is NOT in the tree, then output a line with the following format:

Sorry, item couldn’t be deleted because it’s not in stock.

For choice 3, the first line should read:

Here is a list of the items in stock:

Each following line should have information about one item and the list should be in alphabetical order by item name. Here is the format for one of these lines:

item $price

The price should be printed out to two decimal places exactly.

Finally, for choice 4, print out the sum of the values of all the items in the subtree rooted by the designated item. If this item is NOT in the tree, $0.00 should be printed out. Here is the format for the output for this option.

The value of all the items underneath item is $price.

Implementation Restrictions
You must store the data in nodes of a binary tree. Each binary tree node must store 3 pieces of information: the name of the item, its price, and the sum of the prices of all the items in its subtree.

Sample Input File
11
2 soap
1 soap 2.95
1 raisins 2.00
1 jellybeans 5.00
1 tea 1.95
4 raisins
3
2 raisins
4 soap
4 cereal
1 soap 3.50

Sample Output
Sorry, soap couldn’t be deleted because it’s not in stock.

soap has been added to the stock.

raisins has been added to the stock.

jellybeans has been added to the stock.

tea has been added to the stock.

The value of all the items underneath raisins is $7.00.

Here is a list of the items in stock:
jellybeans $5.00
raisins $2.00
soap $2.95
tea $1.95

raisins has been deleted from the stock.

The value of all the items underneath soap is $9.90.

The value of all the items underneath cereal is $0.00.

Sorry, soap is already in stock. No changes made.

Inventory.c

July 22nd, 2009 Comments off

Project due to me by 6 p.m. EST US time on Jul-22-09.
You are to write a C program that creates and maintains a binary search tree of items in a super market. Each item has a name and a value. All item names will be lowercase alphabetic strings of less than 30 letters. All values will be positive real numbers representing prices. Also, for each node in the tree, you are to maintain the value of all of the items in that subtree. Your tree should be “sorted” based on alphabetical ordering of the item names as determined by strcmp. Your program must allow the user to do the following:

1) Add an item to the inventory
2) Delete an item from the inventory
3) Print out all of the items in the inventory in alphabetical order.
4) Print out the value of all items underneath the subtree of a given item.

For example, if the user adds these items:

a) “soap”, $2.95
b) “raisins”, $2.00
c) “jellybeans”, $5.00
d) “tea”, $1.95

Input File Specification (inventory.txt)
The first line of the input file will contain a single positive integer, n, representing the number of commands to execute. The following n lines will contain one command each, in the other they are to be executed.

The first number of each of these lines will be either 1, 2, 3 or 4, to signify the choices listed above.

If the choice is 1, it will be followed by the name of the item added and its price (as a number), both separated by spaces.

If the choice is 2, it will be followed by the name of the item to be deleted.

Choice 3 will be on a line by itself.

Choice 4 will be followed by a single string storing an item.

Output Specification
For each command, your program should provide some output.
The output provided by each command should be separated by a blank line.

For choice 1, if the item to be added is NOT in the tree, output a line with the following format:

item has been added to the stock.

where item is the name of the item added. If the item is ALREADY in the tree, output a line with the following format:

Sorry, item is already in stock. No changes made.

For choice 2, if the item to be deleted is IN the tree and is successfully deleted, output a line with the following format:

item has been deleted from the stock.

If the item is NOT in the tree, then output a line with the following format:

Sorry, item couldn’t be deleted because it’s not in stock.

For choice 3, the first line should read:

Here is a list of the items in stock:

Each following line should have information about one item and the list should be in alphabetical order by item name. Here is the format for one of these lines:

item $price

The price should be printed out to two decimal places exactly.

Finally, for choice 4, print out the sum of the values of all the items in the subtree rooted by the designated item. If this item is NOT in the tree, $0.00 should be printed out. Here is the format for the output for this option.

The value of all the items underneath item is $price.

Implementation Restrictions
You must store the data in nodes of a binary tree. Each binary tree node must store 3 pieces of information: the name of the item, its price, and the sum of the prices of all the items in its subtree.

Sample Input File
11
2 soap
1 soap 2.95
1 raisins 2.00
1 jellybeans 5.00
1 tea 1.95
4 raisins
3
2 raisins
4 soap
4 cereal
1 soap 3.50

Sample Output
Sorry, soap couldn’t be deleted because it’s not in stock.

soap has been added to the stock.

raisins has been added to the stock.

jellybeans has been added to the stock.

tea has been added to the stock.

The value of all the items underneath raisins is $7.00.

Here is a list of the items in stock:
jellybeans $5.00
raisins $2.00
soap $2.95
tea $1.95

raisins has been deleted from the stock.

The value of all the items underneath soap is $9.90.

The value of all the items underneath cereal is $0.00.

Sorry, soap is already in stock. No changes made.

Simple Binary Tree Inventory

July 21st, 2009 Comments off

You are to write a program that creates and maintains a binary search tree of items in a super market. Each item has a name and a value. All item names will be lowercase alphabetic strings of less than 30 letters. All values will be positive real numbers representing prices. Also, for each node in the tree, you are to maintain the value of all of the items in that subtree. Your tree should be “sorted” based on alphabetical ordering of the item names as determined by strcmp. Your program must allow the user to do the following:

1) Add an item to the inventory
2) Delete an item from the inventory
3) Print out all of the items in the inventory in alphabetical order.
4) Print out the value of all items underneath the subtree of a given item.

For example, if the user adds these items:

a) “soap”, $2.95
b) “raisins”, $2.00
c) “jellybeans”, $5.00
d) “tea”, $1.95

Input File Specification (inventory.txt)
The first line of the input file will contain a single positive integer, n, representing the number of commands to execute. The following n lines will contain one command each, in the other they are to be executed.

The first number of each of these lines will be either 1, 2, 3 or 4, to signify the choices listed above.

If the choice is 1, it will be followed by the name of the item added and its price (as a number), both separated by spaces.

If the choice is 2, it will be followed by the name of the item to be deleted.

Choice 3 will be on a line by itself.

Choice 4 will be followed by a single string storing an item.

Output Specification
For each command, your program should provide some output.
The output provided by each command should be separated by a blank line.

For choice 1, if the item to be added is NOT in the tree, output a line with the following format:

item has been added to the stock.

where item is the name of the item added. If the item is ALREADY in the tree, output a line with the following format:

Sorry, item is already in stock. No changes made.

For choice 2, if the item to be deleted is IN the tree and is successfully deleted, output a line with the following format:

item has been deleted from the stock.

If the item is NOT in the tree, then output a line with the following format:

Sorry, item couldn’t be deleted because it’s not in stock.

For choice 3, the first line should read:

Here is a list of the items in stock:

Each following line should have information about one item and the list should be in alphabetical order by item name. Here is the format for one of these lines:

item $price

The price should be printed out to two decimal places exactly.

Finally, for choice 4, print out the sum of the values of all the items in the subtree rooted by the designated item. If this item is NOT in the tree, $0.00 should be printed out. Here is the format for the output for this option.

The value of all the items underneath item is $price.

Implementation Restrictions
You must store the data in nodes of a binary tree. Each binary tree node must store 3 pieces of information: the name of the item, its price, and the sum of the prices of all the items in its subtree.

Sample Input File
11
2 soap
1 soap 2.95
1 raisins 2.00
1 jellybeans 5.00
1 tea 1.95
4 raisins
3
2 raisins
4 soap
4 cereal
1 soap 3.50

Sample Output
Sorry, soap couldn’t be deleted because it’s not in stock.

soap has been added to the stock.

raisins has been added to the stock.

jellybeans has been added to the stock.

tea has been added to the stock.

The value of all the items underneath raisins is $7.00.

Here is a list of the items in stock:
jellybeans $5.00
raisins $2.00
soap $2.95
tea $1.95

raisins has been deleted from the stock.

The value of all the items underneath soap is $9.90.

The value of all the items underneath cereal is $0.00.

Sorry, soap is already in stock. No changes made.

Binary Searchtree Problem In C

July 20th, 2009 Comments off

You are to write a program that creates and maintains a binary search tree of items in a super market. Each item has a name and a value. All item names will be lowercase alphabetic strings of less than 30 letters. All values will be positive real numbers representing prices. Also, for each node in the tree, you are to maintain the value of all of the items in that subtree. Your tree should be “sorted” based on alphabetical ordering of the item names as determined by strcmp. Your program must allow the user to do the following:

1) Add an item to the inventory
2) Delete an item from the inventory
3) Print out all of the items in the inventory in alphabetical order.
4) Print out the value of all items underneath the subtree of a given item.

For example, if the user adds these items:

a) “soap”, $2.95
b) “raisins”, $2.00
c) “jellybeans”, $5.00
d) “tea”, $1.95

in this order, then the structure of the binary tree would be as follows:

soap 2.95
total: 11.90
/
raisins 2.00 tea 1.95
total: 7.00 total 1.95
/
jellybeans 5.00
total: 5.00

Input File Specification (inventory.txt)
The first line of the input file will contain a single positive integer, n, representing the number of commands to execute. The following n lines will contain one command each, in the other they are to be executed.

The first number of each of these lines will be either 1, 2, 3 or 4, to signify the choices listed above.

If the choice is 1, it will be followed by the name of the item added and its price (as a number), both separated by spaces.

If the choice is 2, it will be followed by the name of the item to be deleted.

Choice 3 will be on a line by itself.

Choice 4 will be followed by a single string storing an item.

Output Specification
For each command, your program should provide some output.
The output provided by each command should be separated by a blank line.

For choice 1, if the item to be added is NOT in the tree, output a line with the following format:

item has been added to the stock.

where item is the name of the item added. If the item is ALREADY in the tree, output a line with the following format:

Sorry, item is already in stock. No changes made.

For choice 2, if the item to be deleted is IN the tree and is successfully deleted, output a line with the following format:

item has been deleted from the stock.

If the item is NOT in the tree, then output a line with the following format:

Sorry, item couldn’t be deleted because it’s not in stock.

For choice 3, the first line should read:

Here is a list of the items in stock:

Each following line should have information about one item and the list should be in alphabetical order by item name. Here is the format for one of these lines:

item $price

The price should be printed out to two decimal places exactly.

Finally, for choice 4, print out the sum of the values of all the items in the subtree rooted by the designated item. If this item is NOT in the tree, $0.00 should be printed out. Here is the format for the output for this option.

The value of all the items underneath item is $price.

Implementation Restrictions
You must store the data in nodes of a binary tree. Each binary tree node must store 3 pieces of information: the name of the item, its price, and the sum of the prices of all the items in its subtree.

Sample Input File
11
2 soap
1 soap 2.95
1 raisins 2.00
1 jellybeans 5.00
1 tea 1.95
4 raisins
3
2 raisins
4 soap
4 cereal
1 soap 3.50

Sample Output
Sorry, soap couldn’t be deleted because it’s not in stock.

soap has been added to the stock.

raisins has been added to the stock.

jellybeans has been added to the stock.

tea has been added to the stock.

The value of all the items underneath raisins is $7.00.

Here is a list of the items in stock:
jellybeans $5.00
raisins $2.00
soap $2.95
tea $1.95

raisins has been deleted from the stock.

The value of all the items underneath soap is $9.90.

The value of all the items underneath cereal is $0.00.

Sorry, soap is already in stock. No changes made.

PS: I may not answer right away to you bids, so after you bid please allow some time for answer.

Program Using Queues In C

July 7th, 2009 Comments off

The Problem
A university lacks a credible grocery store on campus. After a year of getting lousy over-priced food in the convenience store in the Student Union, you and all of your friends are frustrated. One of your friends majoring in business comes up with the brilliant idea of opening a grocery store on campus. But, they need your help to decide if their idea is viable or not. Your job will be to run various simulations of customers in line.

The model for the store is as follows:

Normally, there will be three lines in operation or customers to buy their groceries. Each line will have a capacity of 8 customers. The first line (line A) will only be for customers with 10 or fewer items. The other two lines (line B and C) will be for all customers. When a customer is ready to check out, here is how they decide what line to go to:

If the customer has 10 or fewer items and the

Text Messaging Censoring

April 26th, 2009 Comments off

Objective
To give students practice at writing a program using strings.

The Problem
Many people, after a late night, for whatever reason, tend to send emails or text messages that they shouldn

Categories: C/C++ Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Text Censoring In C Program

April 22nd, 2009 Comments off

Restrictions — MUST be in plain old C — NOT C++ and compile with DevC++ compiler as a .c file — Need an input dictionary file with at least 30,000 words to validate spelling.

The Problem
Many people, after a late night, for whatever reason, tend to send emails or text messages that they shouldn

Text Censoring In C Program

April 11th, 2009 Comments off

Restrictions — MUST be in plain old C — NOT C++ and compile with DevC++ compiler as a .c file — Need an input dictionary file with at least 30,000 words to validate spelling.

The Problem
Many people, after a late night, for whatever reason, tend to send emails or text messages that they shouldn

Text Messaging Censoring

April 10th, 2009 Comments off

Objective
To give students practice at writing a program using strings.

The Problem
Many people, after a late night, for whatever reason, tend to send emails or text messages that they shouldn

Bear