Archive

Posts Tagged ‘num’

Ipn Mlm Script – Take 4

July 16th, 2009 Comments off

I’m looking for a script to do something like what the dreammakersnetwork site did back in like 2002 if anyone remembers that mlm program. It was one of the fastest growing on-line businesses that even had media attention on TV. Then one day it was all gone. I’ve done searches for scripts or that but nothing found as yet.

This is what I’d like the script to do. Basic minimum html needed as I can modify the looks once done. just enough to give a basic look is all.

main page blahhhh info about the business etc.. & signup link
Signup will only place them. to be an active affiliate they will need to become “active” by clicking the be active link which is a link to monthly subscription to the [product] club. music/ebooks/software

there will be 2 types of “active” here
1: active member meaning they signed up and joined the club by activating monthly subscription to the club
2: VIP member meaning they signed up and joined the club by activating monthly club dues and purchased the set number of purchases. (more on this below (A1) becoming a VIP, that member is eligible to get sales on [product] (more on that below also (A2))

being active will allow that person to get credit for referrals and build a downline. unless they are active. Referrals from that person’s url goes upline to the next “active” affiliate.

A VIP will get full credit for all referrals’ from sales of [product] [downline] which is set by site config

here is what the [product] page for purchases will look:
————————-
HEADER.inc.tpl

Website owner [website product of month] [buy IPN] [red][green]
$UPLINE 1 ID [product 1] [buy IPN] [red]or[green]light
$UPLINE 2 ID [product 2] [buy IPN] [red]or[green]light
$UPLINE 3 ID [product 3] [buy IPN] [red]or[green]light
$UPLINE 4 ID [product 4] [buy IPN] [red]or[green]light
$UPLINE 5 ID [product 5] [buy IPN] [red]or[green]light
$UPLINE 6 ID [product 6] [buy IPN] [red]or[green]light
$UPLINE 7 ID [product 7] [buy IPN] [red]or[green]light
$UPLINE 8 ID [product 8] [buy IPN] [red]or[green]light
$UPLINE 9 ID [product 9] [buy IPN] [red]or[green]light

footer.inc.tpl
————————-
{$UPLINE 1 ID}is determined by “ACTIVE” status. the website that the referred comes in by websiteurl?id=[ID]
if the [ID] is not a VIP then the {$UPLINE 1 ID} is the next [ID] upline from that referring [ID] that is VIP.

{$UPLINE 2 ID} then is the next VIP upline of {$UPLINE 1 ID}
etc etc etc
IF no VIP to fill up the table then VIP=Site Owner like below:

Website owner [website product of month] [buy IPN] [red][green]
$UPLINE 1 ID [product 1] [buy IPN] [red]or[green]light
$UPLINE 2 ID [product 2] [buy IPN] [red]or[green]light
$UPLINE 3 ID [product 3] [buy IPN] [red]or[green]light
$UPLINE 4 ID [product 4] [buy IPN] [red]or[green]light
$UPLINE 5 ID [product 5] [buy IPN] [red]or[green]light
$UPLINE 6 DID [product 6] [buy IPN] [red]or[green]light
$UPLINE 7 DID [product 7] [buy IPN] [red]or[green]light
$UPLINE 8 DID [product 8] [buy IPN] [red]or[green]light
$UPLINE 9 DID [product 9] [buy IPN] [red]or[green]light

DID = Default ID which is ID given to Site OWNER

The operation of this page should be as follows:
The member wishes to become a VIP and is at the above listed page
they click on [buy IPN] of product to purchase. it does the IPN thing with PayPal and when finished with IPN process it returns affiliate to the same page and the item they purchased turns to a GREEN LIGHT PIC like below:

Website owner [website product of month] [buy IPN] [red]
$UPLINE 1 ID [product 1] [buy IPN] [red]
$UPLINE 2 ID [product 2] [buy IPN] [red]
$UPLINE 3 ID [product 3] [buy IPN] [red]
$UPLINE 4 ID [product 4] [buy IPN] [green] showing this was purchased

RED showing what is NEEDED yet to be purchased to fulfill requirements to become a VIP

The affilate then clicks on the next product and does the IPN thing and when IPN returns to the page it looks like the following showing the items purchased AND LINK TO DOWNLOAD PRODUCT.:

Website owner [website product of month] [buy IPN] [red]
$UPLINE 1 ID [product 1] [buy IPN] [red]
$UPLINE 2 ID [product 2] [buy IPN] [red]
$UPLINE 3 ID [product 3] [buy IPN] [GREEN] [DOWNLOAD PRODUCT]
$UPLINE 4 ID [product 4] [buy IPN] [GREEN] [DOWNLOAD PRODUCT]

this goes on until all products are purchased on the page. Once all products are purchased, the affiliate is then a VIP

MYSQL database will have something like :
affiliate (yes)
VIP (yes)

SPECIAL IMPORTANT NOTE ABOUT [buy IPN]
The [buy IPN] for that product is linked to [ID]‘s paypal (not websites, unless [ID] = DID
for example:

Website owner [website product of month] [buy IPN] [red]
JOSH [product 1] [JOSH'S PAYPAL IPN] [red]
JANE [product 2] [JANE'S PAYPAL IPN] [red]
JACK [product 3] [JACK'S PAYPAL IPN] [GREEN] [DOWNLOAD PRODUCT]
JILL [product 4] [JILL'S PAYPAL IPN] [GREEN] [DOWNLOAD PRODUCT]

SO IN THE ABOVE SCENARIO JOSH,JANE,JACK & JILL WILL BE PAID DIRECTLY

once product is purchased, an email is sent to the person that purchased it along with a random generated password that is needed to access that link to download product. that password to be valid for set amount of time determined by CONF. 1-24 hours i guess..
each item purchased will when purchased have it’s own password to access that file.

I think you have the idea of this part. NOW for affiliate options
—————————–
ADMIN/SITE OWNER FUNCTIONS
ability to edit templates
edit email templates
edit CONF setup
- $NUM_PRODUCTS (this will determine how deep the page goes.

If $NUM_PRODUCTS = 4 then the page will look like:

Website owner [website product of month] [buy IPN] [red]
$UPLINE 1 ID [product 1] [buy IPN] [red]
$UPLINE 2 ID [product 2] [buy IPN] [red]
$UPLINE 3 ID [product 3] [buy IPN] [red]
$UPLINE 4 ID [product 4] [buy IPN] [red]

If $NUM_PRODUCTS = 9 then the page will look like:

Website owner [website product of month] [buy IPN] [red]
$UPLINE 1 ID [product 1] [buy IPN] [red]
$UPLINE 2 ID [product 2] [buy IPN] [red]
$UPLINE 3 ID [product 3] [buy IPN] [red]
$UPLINE 4 ID [product 4] [buy IPN] [red]
$UPLINE 5 ID [product 5] [buy IPN] [red]
$UPLINE 6 ID [product 6] [buy IPN] [red]
$UPLINE 7 ID [product 7] [buy IPN] [red]
$UPLINE 8 ID [product 8] [buy IPN] [red]
$UPLINE 9 ID [product 9] [buy IPN] [red]

If $NUM_PRODUCTS = 9 then the page will look like: you get the idea…

- to set the price of each [product] in CONF (nice is all are the same but the ability to set price on product makes things interesting for the affiliates. etc as shown in example below:
[product 0=product of the month][description][image][price]
[product 1][description][image][price]
[product 2][description][image][price]
[product 3][description][image][price]
[product 4][description][image][price]

so the page will look like this to affiliates:

site owner [eBook - Making Money] [imgthumb] [$5.00][buy IPN][red]
$UPLINE 1 ID [eBook - My Ford & You][imgthumb] [$5.00][buy IPN][red]
$UPLINE 2 ID [eBook - Money 101] [imgthumb][$10.00][buy IPN][red]
$UPLINE 3 ID [eBook - Cooking 101] [imgthumb][$15.00][buy IPN][red]
$UPLINE 4 ID [eBook - PHP & You] [imgthumb] [$5.00][buy IPN][red]

the Products will be set for each level by admin. so if done like above the uplines 2 & 3 will get more money if that product is set that way.

- the basic CONF items. more the better to make it fully customizable to the site owner
—————————–
EMAILS SENT
- when a signup under ID (if affiliate or VIP) this way the affiliate sees what they are missing
- when someone upgrades to VIP send email notification to upline
$NUM_PRODUCTS = $upline emails sent to VIP’s
- email to site owner when someone signs up
- when someone upgrades to VIP
CONF Abilities to turn each email off (in case of spam issues)

—————————–
affiliate center – for all to view their stats
ADMIN CONF to set who can view what in affcenter like:
[CAN VIEW] [AFF] [VIP] [SITE OWNER]
list of VIP’s in downline YES YES ….
list of complete downline limit 10 YES
email downline
view upline ID
view upline ID/NAMES
view weekly earning
view monthly earning
view total earnings
email sponsor upline who referred them
—————————–
i guess this is enough for now. I think you get the msg. The basic task is to produce a system that is a money maker for everyone involved. Keep in mind also a way to plug into this so maybe members can upgrade even to more levels if this goes that far.

IPN to be used in conjunction with PayPal
products offered will only be downloaded product.
Will be installed on a Linux system

Options for winning programmer to become more involved in this project once it is on-line and to reap the benefits also. perhaps do another
product option aside from site owner like:

programmer’s piece of pie [special product of month] [buy IPN] [red]
so that you get money each time there is an upgrade to VIP

_____________________________________________________
please do not bid on this if you can not understand English or do not respond to questions when asked. This is the 4th time I’ve posted this project and have yet to find someone that is able to respond to msg’s when asked.
_____________________________________________________

Ipn Mlm Script

June 2nd, 2009 Comments off

I’m looking for a script to do something like what the dreammakersnetwork site did back in like 2002 if anyone remembers that mlm program. It was one of the fastest growing on-line businesses that even had media attention on TV. Then one day it was all gone. I’ve done searches for scripts or that but nothing found as yet.

This is what I’d like the script to do. Basic minimum html needed as I can modify the looks once done. just enough to give a basic look is all.

main page blahhhh info about the business etc.. & signup link
Signup will only place them. to be an active affiliate they will need to become “active” by clicking the be active link which is a link to monthly subscription to the [product] club. music/ebooks/software

there will be 2 types of “active” here
1: active member meaning they signed up and joined the club by activating monthly subscription to the club
2: VIP member meaning they signed up and joined the club by activating monthly club dues and purchased the set number of purchases. (more on this below (A1) becoming a VIP, that member is eligible to get sales on [product] (more on that below also (A2))

being active will allow that person to get credit for referrals and build a downline. unless they are active. Referrals from that person’s url goes upline to the next “active” affiliate.

A VIP will get full credit for all referrals’ from sales of [product] [downline] which is set by site config

here is what the [product] page for purchases will look:
————————-
HEADER.inc.tpl

Website owner [website product of month] [buy IPN] [red][green]
$UPLINE 1 ID [product 1] [buy IPN] [red]or[green]light
$UPLINE 2 ID [product 2] [buy IPN] [red]or[green]light
$UPLINE 3 ID [product 3] [buy IPN] [red]or[green]light
$UPLINE 4 ID [product 4] [buy IPN] [red]or[green]light
$UPLINE 5 ID [product 5] [buy IPN] [red]or[green]light
$UPLINE 6 ID [product 6] [buy IPN] [red]or[green]light
$UPLINE 7 ID [product 7] [buy IPN] [red]or[green]light
$UPLINE 8 ID [product 8] [buy IPN] [red]or[green]light
$UPLINE 9 ID [product 9] [buy IPN] [red]or[green]light

footer.inc.tpl
————————-
{$UPLINE 1 ID}is determined by “ACTIVE” status. the website that the referred comes in by websiteurl?id=[ID]
if the [ID] is not a VIP then the {$UPLINE 1 ID} is the next [ID] upline from that referring [ID] that is VIP.

{$UPLINE 2 ID} then is the next VIP upline of {$UPLINE 1 ID}
etc etc etc
IF no VIP to fill up the table then VIP=Site Owner like below:

Website owner [website product of month] [buy IPN] [red][green]
$UPLINE 1 ID [product 1] [buy IPN] [red]or[green]light
$UPLINE 2 ID [product 2] [buy IPN] [red]or[green]light
$UPLINE 3 ID [product 3] [buy IPN] [red]or[green]light
$UPLINE 4 ID [product 4] [buy IPN] [red]or[green]light
$UPLINE 5 ID [product 5] [buy IPN] [red]or[green]light
$UPLINE 6 DID [product 6] [buy IPN] [red]or[green]light
$UPLINE 7 DID [product 7] [buy IPN] [red]or[green]light
$UPLINE 8 DID [product 8] [buy IPN] [red]or[green]light
$UPLINE 9 DID [product 9] [buy IPN] [red]or[green]light

DID = Default ID which is ID given to Site OWNER

The operation of this page should be as follows:
The member wishes to become a VIP and is at the above listed page
they click on [buy IPN] of product to purchase. it does the IPN thing with PayPal and when finished with IPN process it returns affiliate to the same page and the item they purchased turns to a GREEN LIGHT PIC like below:

Website owner [website product of month] [buy IPN] [red]
$UPLINE 1 ID [product 1] [buy IPN] [red]
$UPLINE 2 ID [product 2] [buy IPN] [red]
$UPLINE 3 ID [product 3] [buy IPN] [red]
$UPLINE 4 ID [product 4] [buy IPN] [green] showing this was purchased

RED showing what is NEEDED yet to be purchased to fulfill requirements to become a VIP

The affilate then clicks on the next product and does the IPN thing and when IPN returns to the page it looks like the following showing the items purchased AND LINK TO DOWNLOAD PRODUCT.:

Website owner [website product of month] [buy IPN] [red]
$UPLINE 1 ID [product 1] [buy IPN] [red]
$UPLINE 2 ID [product 2] [buy IPN] [red]
$UPLINE 3 ID [product 3] [buy IPN] [GREEN] [DOWNLOAD PRODUCT]
$UPLINE 4 ID [product 4] [buy IPN] [GREEN] [DOWNLOAD PRODUCT]

this goes on until all products are purchased on the page. Once all products are purchased, the affiliate is then a VIP

MYSQL database will have something like :
affiliate (yes)
VIP (yes)

SPECIAL IMPORTANT NOTE ABOUT [buy IPN]
The [buy IPN] for that product is linked to [ID]‘s paypal (not websites, unless [ID] = DID
for example:

Website owner [website product of month] [buy IPN] [red]
JOSH [product 1] [JOSH'S PAYPAL IPN] [red]
JANE [product 2] [JANE'S PAYPAL IPN] [red]
JACK [product 3] [JACK'S PAYPAL IPN] [GREEN] [DOWNLOAD PRODUCT]
JILL [product 4] [JILL'S PAYPAL IPN] [GREEN] [DOWNLOAD PRODUCT]

SO IN THE ABOVE SCENARIO JOSH,JANE,JACK & JILL WILL BE PAID DIRECTLY

once product is purchased, an email is sent to the person that purchased it along with a random generated password that is needed to access that link to download product. that password to be valid for set amount of time determined by CONF. 1-24 hours i guess..
each item purchased will when purchased have it’s own password to access that file.

I think you have the idea of this part. NOW for affiliate options
—————————–
ADMIN/SITE OWNER FUNCTIONS
ability to edit templates
edit email templates
edit CONF setup
- $NUM_PRODUCTS (this will determine how deep the page goes.

If $NUM_PRODUCTS = 4 then the page will look like:

Website owner [website product of month] [buy IPN] [red]
$UPLINE 1 ID [product 1] [buy IPN] [red]
$UPLINE 2 ID [product 2] [buy IPN] [red]
$UPLINE 3 ID [product 3] [buy IPN] [red]
$UPLINE 4 ID [product 4] [buy IPN] [red]

If $NUM_PRODUCTS = 9 then the page will look like:

Website owner [website product of month] [buy IPN] [red]
$UPLINE 1 ID [product 1] [buy IPN] [red]
$UPLINE 2 ID [product 2] [buy IPN] [red]
$UPLINE 3 ID [product 3] [buy IPN] [red]
$UPLINE 4 ID [product 4] [buy IPN] [red]
$UPLINE 5 ID [product 5] [buy IPN] [red]
$UPLINE 6 ID [product 6] [buy IPN] [red]
$UPLINE 7 ID [product 7] [buy IPN] [red]
$UPLINE 8 ID [product 8] [buy IPN] [red]
$UPLINE 9 ID [product 9] [buy IPN] [red]

If $NUM_PRODUCTS = 9 then the page will look like: you get the idea…

- to set the price of each [product] in CONF (nice is all are the same but the ability to set price on product makes things interesting for the affiliates. etc as shown in example below:
[product 0=product of the month][description][image][price]
[product 1][description][image][price]
[product 2][description][image][price]
[product 3][description][image][price]
[product 4][description][image][price]

so the page will look like this to affiliates:

site owner [eBook - Making Money] [imgthumb] [$5.00][buy IPN][red]
$UPLINE 1 ID [eBook - My Ford & You][imgthumb] [$5.00][buy IPN][red]
$UPLINE 2 ID [eBook - Money 101] [imgthumb][$10.00][buy IPN][red]
$UPLINE 3 ID [eBook - Cooking 101] [imgthumb][$15.00][buy IPN][red]
$UPLINE 4 ID [eBook - PHP & You] [imgthumb] [$5.00][buy IPN][red]

the Products will be set for each level by admin. so if done like above the uplines 2 & 3 will get more money if that product is set that way.

- the basic CONF items. more the better to make it fully customizable to the site owner
—————————–
EMAILS SENT
- when a signup under ID (if affiliate or VIP) this way the affiliate sees what they are missing
- when someone upgrades to VIP send email notification to upline
$NUM_PRODUCTS = $upline emails sent to VIP’s
- email to site owner when someone signs up
- when someone upgrades to VIP
CONF Abilities to turn each email off (in case of spam issues)

—————————–
affiliate center – for all to view their stats
ADMIN CONF to set who can view what in affcenter like:
[CAN VIEW] [AFF] [VIP] [SITE OWNER]
list of VIP’s in downline YES YES ….
list of complete downline limit 10 YES
email downline
view upline ID
view upline ID/NAMES
view weekly earning
view monthly earning
view total earnings
email sponsor upline who referred them
—————————–
i guess this is enough for now. I think you get the msg. The basic task is to produce a system that is a money maker for everyone involved. Keep in mind also a way to plug into this so maybe members can upgrade even to more levels if this goes that far.

IPN to be used in conjunction with PayPal
products offered will only be downloaded product.
Will be installed on a Linux system

Options for winning programmer to become more involved in this project once it is on-line and to reap the benefits also. perhaps do another
product option aside from site owner like:

programmer’s piece of pie [special product of month] [buy IPN] [red]
so that you get money each time there is an upgrade to VIP

Upd. Num Values From Web Pages

April 12th, 2009 Comments off

I have the attached page, which has 3 values and an “Update” button to submit them.

I need a script that updates the 2nd and 3rd value from the web and submit.

Description of the second value: it’s simply the value in euro of 100 US dollars. The script must grab it from a popular value exchange site (for example finance.yahoo.com, oanda.com or xe.com).

The third value is the value in euro of 65 DTS. The value of 1 DTS in euro is defined in this page http://www.imf.org/external/np/fin/data/rms_five.aspx#cvsdr and it’s currently 1.124670 (the script should take the last shown day, even if it’s some days ago). The script must grab it there.
Note: SDR = DTS.

Both the values must be entered with two decimals.

In case the new value is different of more than 2% of the old value or is not in the correct format (number with two decimals), the script must show a red error/warning message showing the old and new values and must NOT submit them both, even if the error is for only one of them.

In addition, it must update in my homepage (make a sample page to test this, I will copy the code by myself to my homepage) an information box that has a text in this form “5/4/09: updated values 65 DTS = 72.63, $100 = 74.17″. I.e. it must update the date (format d/m/yy) and the two numbers.

Must be cross browser.

Escrow offered.

C Lemonade Stand

April 5th, 2009 Comments off

Here is what needs to be done. I have the skeleton code too which i have included right after the instructions. This program must compile in Dev C++ and it needs to be in the format in the instructions.

Objectives
1. Review use of if statements and loops.
2. Learn how to write functions given specifications.
3. Learn how to use pass by reference variables.
4. Learn how to put together a useful program given a skeleton of that program and the
functions and their specifications necessary in the implementation.

Problem: Lemonade Stand
Last summer your friend has a lemonade stand and made lots of money. You want to do the same! You have plenty of time to plan, so you thought you would be pre
pared when summer came around by writing a program to simulate your lemonade stand. The basic idea behind the simulation is as follows:

1) You will simulate 10 days of running the lemonade stand.
2) In the beginning the user gets a $20.00 loan to run the lemonade stand.
3) Before each day, the user gets an opportunity to buy bags of lemons and sugar.
4) At the beginning of each day the user receive a weather report.
5) Based on that, the user is asked to price a cup of lemonade for that day.
6) Then, the days sales are simulated. (Part of this is written for you.)
7) Afterwards, the user is prompted with a status report of how much money they have left and how many bags of lemons and sugar they have left.

What you have to do
A skeleton of the solution for this assignment is posted on WebCourses and the course web page. Please use this skeleton. You must fill in the seven functions that are left for you to fill in, as well as write the remainder of main so the program works as described above. After you write each function, you should test it before moving on. How to do this will be covered in class. Then, write your main, calling the necessary functions from it to achieve the desired functionality. main can work without declaring any new variables than the ones already declared. But, you may declare new ones if you wish.

Perhaps the biggest problem you will have will be not knowing when to make function calls. The goal of having these functions is to make the coding process more manageable. In particular, it is possible that a function might “do” something complicated, but that just really means that function makes calls to other functions that carry out a majority of that work already. In essence, if you write a function A to do a task, then don’t write out the code that also does that task in another function B. Instead call the function A from the body of function B.

References
Textbook: Chapters 9, 10, 11 Notes: Lectures 13, 14, 15, 17

Output Sample
Two full output samples of the program running will be provided on Webcourses and the course web page in the files lemonade.out and lemonade2.out.

Deliverables
You must submit your solution to the problem, lemonade.c, over WebCourses.

Restrictions
Although you may use other compilers, your program must compile and run using DevC++. Please use DevC++ to develop your program. Your program should include a header comment with the following information: your name, course number, section number, assignment title, and date. Also, make sure you include ample comments throughout your code describing the major steps in solving the problem.

Grading Details
Your program will be graded upon the following criteria:

1) Your correctness
2) Your programming style and use of white space. (Even if you have a plan and your program works perfectly, if your programming style is poor or your use of white space is poor you could get 10% or 15% deducted from your grade.)
3) Compatibility to DevC++. (If your program does not compile in this environment, you will get a sizable deduction from your grade, likely to be over 50%)

The code Skeleton:

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

// Symbolic constants to be used.

// Prices of bags of sugar and lemon, respectively.
#define PRICE_LEMON 3.50
#define PRICE_SUGAR 2.00

// Fraction of a bag of lemons and sugar used on a single cup of lemonade.
#define LEMON_PER_CUP 0.03
#define SUGAR_PER_CUP 0.04

// The initial loan the user is given to start their lemonade stand.
#define START_MONEY 20.00

// Using symbolic constants for true and false.
#define FALSE 0
#define TRUE 1

void buy_lemons(double *pLemons, double *pMoney);
void buy_sugar(double *pSugar, double *pMoney);
int weather();
int num_cups_sold(int weather, int cost);
void status_report(double cash, double num_lemons, double num_sugar, int day);
int max_sell(double num_lemons, double num_sugar);
int get_cost();
void sell_cups(double *pMoney, double *pLemons, double *pSugar);
void end_message(double money);

int main() {

int num_day, ans;
double money = START_MONEY, num_lemons = 0, num_sugar = 0;

srand(time(0));

printf(“Welcome to the Game of Lemonade!nn”);
printf(“You start the game with $%.2lf and no supplies!n”, START_MONEY);

// Loop through each day. Ask the user if they want to buy lemons. If so,
// carry out the transaction. Then ask them if they want to buy sugar.
// If so, do this transaction as well. Then, let them sell lemonade for
// the day. Finally, print a status report after they’ve sold lemonade
// at the end of the day.
for (num_day = 1; num_day <= 10; num_day++) {

}

// Print out whether or not they have lost money, broke even or gained
// money.

return 0;
}

// Pre-conditions: pLemons and pMoney are pointers to variables that store
// the user’s number of bags of lemons left and amount of
// money left.
// Post-condition: The user is given the opportunity to buy lemons. If
// successful, the number of bags of lemons and the amount
// of money the user has are adjusted accordingly.
//
// What to do in this function: If the user doesn’t have enough money to
// even buy one bag of lemons, tell them so and return. Otherwise, ask
// the user how many bags of lemons they want to buy. If they answer less
// than one, tell them they must get more and reprompt them. If they
// answer more than they can buy, tell them they don’t have that much
// money and reprompt them. Continue prompting them until they answer with
// a valid value. Then process the transaction.

void buy_lemons(double *pLemons, double *pMoney) {

}

// Pre-conditions: pSugar and pMoney are pointers to variables that store
// the user’s number of bags of lemons left and amount of
// money left.
// Post-condition: The user is given the opportunity to buy sugar. If
// successful, the number of bags of sugar and the amount
// of money the user has are adjusted accordingly.
//
// What to do in this function: If the user doesn’t have enough money to
// even buy one bag of sugar, tell them so and return. Otherwise, ask
// the user how many bags of sugar they want to buy. If they answer less
// than one, tell them they must get more and reprompt them. If they
// answer more than they can buy, tell them they don’t have that much
// money and reprompt them. Continue prompting them until they answer with
// a valid value. Then process the transaction.

void buy_sugar(double *pSugar, double *pMoney) {

}

// Pre-condition: None
// Post-condition: The weather report for the day is printed and the
// corresponding weather status in between 1 and 5,
// inclusive, is returned.
int weather() {

// Get the weather status value.
int retval = rand()%5 + 1;

printf(“nHere is today’s weather forecast:n”);

// Print out the appropriate forecast for that status.n”);
if (retval == 1)
printf(“It is cloudy with a high chance of rain.n”);
else if (retval == 2)
printf(“It is partly cloudy and windy.n”);
else if (retval == 3)
printf(“It is partly sunny with low humidity.n”);
else if (retval == 4)
printf(“It is warm and sunny with medium winds.n”);
else
printf(“It’s a perfect beach day. Sunny and hot!n”);

return retval; // Return this status value.
}

// Pre-condition: weather is an integer in between 1 and 5, inclusive,
// standing for the weather status for the day. cost is
// the cost of a cup of lemonade in cents for that day.
// Post-condition: The number of cups of lemonade for that day is returned.
int num_cups_sold(int weather, int cost) {

int optimal_price, max_cups;
double max_income;

// Calculate a maximum revenue for the day.
max_income = 5 + 3*weather;
optimal_price = 15 + 5*weather;
max_income = max_income – fabs(optimal_price – cost)/1.5;

// If it’s lower than 5 dollars, reset it to 5 dollars.
if (max_income < 5)
max_income = 5;

// From this, determine the maximum number of cups that could be sold.
max_cups = (int)(max_income/((double)cost/100));

// Return a random number from 0 to this maximum.
return rand()%(max_cups+1);

}

// Pre-condition: cash is the amount of cash the user has, num_lemons is
// the number of bags of lemons the user has left, num_sugar
// is the number of bags of sugar the user has left, and day
// is which day of the game just finished.
// Post-condition: A status report with the four values passed in is nicely
// displayed for the user.
//
// What to do with this function: This is fairly self-explanatory from the
// pre and post conditions. Look to the sample given in the assignment for
// the format.
void status_report(double cash, double num_lemons, double num_sugar, int day) {

}

// Pre-condition: pMoney, pLemons and pSugar are pointers to the variables
// storing the user’s amount of cash, number of bags of
// lemons and number of bags of sugar.
// Post-condition: A day’s transactions will take place and the amount of
// money, the number of bags of lemons and sugar will be
// adjusted accordingly.
//
// What to do with this function: First prompt the user with the weather
// report. Then, ask the user for how much they want to sell a cup of
// lemonade. Determine the number of cups that actually get sold for the
// day by determining how many cups the user COULD sell based on the
// availability of supplies and how many cups they COULD sell based on the
// weather. Print out how many cups of lemonade they ended up selling.
// Then adjust the amount of money they have, as well as the number of bags
// of lemons and sugar.

void sell_cups(double *pMoney, double *pLemons, double *pSugar) {

}

// Pre-condition: num_lemons is the number of bags of lemons the user has,
// and num_sugar is the number of bags of sugar they have.
// Post-condition: The function returns the maximum number of cups of
// lemonade the user can sell based on available supplies.
//
// What to do with this function: Calculate how many full cups of lemonade
// you can supply with sugar. Do the same calculation for lemons. Then,
// return the smaller of these two values.

int max_sell(double num_lemons, double num_sugar) {

}

// Pre-condition: None.
// Post-condition: Returns the number of cents the user will sell a cup of
// lemonade for, for that day.
//
// What to do with this function: Prompt the user to enter how much they
// want to charge for a cup of lemonade. If they don’t enter a positive
// integer, reprompt them until they do. Then return this value.

int get_cost() {

}

// Pre-condition: money is the amount of money the user has left at the end
// of the 10 days of running their Lemonade Stand.
// Post-condition: The user’s overall loss or profit is printed out.

// What to do with this function: See if what they have left is less than
// what they started with. If so, print out how much the lost. If it’s equal
// just print out a message saying that they broke even. Otherwise, print
// out how much profit they made!

void end_message(double money) {

}

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

Lemonade Stand

April 3rd, 2009 Comments off

Here is what needs to be done. I have the skeleton code too which i have included right after the instructions. This program must compile in Dev C++ and it needs to be in the format in the instructions.

Objectives
1. Review use of if statements and loops.
2. Learn how to write functions given specifications.
3. Learn how to use pass by reference variables.
4. Learn how to put together a useful program given a skeleton of that program and the
functions and their specifications necessary in the implementation.

Problem: Lemonade Stand
Last summer your friend has a lemonade stand and made lots of money. You want to do the same! You have plenty of time to plan, so you thought you would be pre
pared when summer came around by writing a program to simulate your lemonade stand. The basic idea behind the simulation is as follows:

1) You will simulate 10 days of running the lemonade stand.
2) In the beginning the user gets a $20.00 loan to run the lemonade stand.
3) Before each day, the user gets an opportunity to buy bags of lemons and sugar.
4) At the beginning of each day the user receive a weather report.
5) Based on that, the user is asked to price a cup of lemonade for that day.
6) Then, the days sales are simulated. (Part of this is written for you.)
7) Afterwards, the user is prompted with a status report of how much money they have left and how many bags of lemons and sugar they have left.

What you have to do
A skeleton of the solution for this assignment is posted on WebCourses and the course web page. Please use this skeleton. You must fill in the seven functions that are left for you to fill in, as well as write the remainder of main so the program works as described above. After you write each function, you should test it before moving on. How to do this will be covered in class. Then, write your main, calling the necessary functions from it to achieve the desired functionality. main can work without declaring any new variables than the ones already declared. But, you may declare new ones if you wish.

Perhaps the biggest problem you will have will be not knowing when to make function calls. The goal of having these functions is to make the coding process more manageable. In particular, it is possible that a function might “do” something complicated, but that just really means that function makes calls to other functions that carry out a majority of that work already. In essence, if you write a function A to do a task, then don’t write out the code that also does that task in another function B. Instead call the function A from the body of function B.

References
Textbook: Chapters 9, 10, 11 Notes: Lectures 13, 14, 15, 17

Output Sample
Two full output samples of the program running will be provided on Webcourses and the course web page in the files lemonade.out and lemonade2.out.

Deliverables
You must submit your solution to the problem, lemonade.c, over WebCourses.

Restrictions
Although you may use other compilers, your program must compile and run using DevC++. Please use DevC++ to develop your program. Your program should include a header comment with the following information: your name, course number, section number, assignment title, and date. Also, make sure you include ample comments throughout your code describing the major steps in solving the problem.

Grading Details
Your program will be graded upon the following criteria:

1) Your correctness
2) Your programming style and use of white space. (Even if you have a plan and your program works perfectly, if your programming style is poor or your use of white space is poor you could get 10% or 15% deducted from your grade.)
3) Compatibility to DevC++. (If your program does not compile in this environment, you will get a sizable deduction from your grade, likely to be over 50%)

The code Skeleton:

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

// Symbolic constants to be used.

// Prices of bags of sugar and lemon, respectively.
#define PRICE_LEMON 3.50
#define PRICE_SUGAR 2.00

// Fraction of a bag of lemons and sugar used on a single cup of lemonade.
#define LEMON_PER_CUP 0.03
#define SUGAR_PER_CUP 0.04

// The initial loan the user is given to start their lemonade stand.
#define START_MONEY 20.00

// Using symbolic constants for true and false.
#define FALSE 0
#define TRUE 1

void buy_lemons(double *pLemons, double *pMoney);
void buy_sugar(double *pSugar, double *pMoney);
int weather();
int num_cups_sold(int weather, int cost);
void status_report(double cash, double num_lemons, double num_sugar, int day);
int max_sell(double num_lemons, double num_sugar);
int get_cost();
void sell_cups(double *pMoney, double *pLemons, double *pSugar);
void end_message(double money);

int main() {

int num_day, ans;
double money = START_MONEY, num_lemons = 0, num_sugar = 0;

srand(time(0));

printf(“Welcome to the Game of Lemonade!nn”);
printf(“You start the game with $%.2lf and no supplies!n”, START_MONEY);

// Loop through each day. Ask the user if they want to buy lemons. If so,
// carry out the transaction. Then ask them if they want to buy sugar.
// If so, do this transaction as well. Then, let them sell lemonade for
// the day. Finally, print a status report after they’ve sold lemonade
// at the end of the day.
for (num_day = 1; num_day <= 10; num_day++) {

}

// Print out whether or not they have lost money, broke even or gained
// money.

return 0;
}

// Pre-conditions: pLemons and pMoney are pointers to variables that store
// the user’s number of bags of lemons left and amount of
// money left.
// Post-condition: The user is given the opportunity to buy lemons. If
// successful, the number of bags of lemons and the amount
// of money the user has are adjusted accordingly.
//
// What to do in this function: If the user doesn’t have enough money to
// even buy one bag of lemons, tell them so and return. Otherwise, ask
// the user how many bags of lemons they want to buy. If they answer less
// than one, tell them they must get more and reprompt them. If they
// answer more than they can buy, tell them they don’t have that much
// money and reprompt them. Continue prompting them until they answer with
// a valid value. Then process the transaction.

void buy_lemons(double *pLemons, double *pMoney) {

}

// Pre-conditions: pSugar and pMoney are pointers to variables that store
// the user’s number of bags of lemons left and amount of
// money left.
// Post-condition: The user is given the opportunity to buy sugar. If
// successful, the number of bags of sugar and the amount
// of money the user has are adjusted accordingly.
//
// What to do in this function: If the user doesn’t have enough money to
// even buy one bag of sugar, tell them so and return. Otherwise, ask
// the user how many bags of sugar they want to buy. If they answer less
// than one, tell them they must get more and reprompt them. If they
// answer more than they can buy, tell them they don’t have that much
// money and reprompt them. Continue prompting them until they answer with
// a valid value. Then process the transaction.

void buy_sugar(double *pSugar, double *pMoney) {

}

// Pre-condition: None
// Post-condition: The weather report for the day is printed and the
// corresponding weather status in between 1 and 5,
// inclusive, is returned.
int weather() {

// Get the weather status value.
int retval = rand()%5 + 1;

printf(“nHere is today’s weather forecast:n”);

// Print out the appropriate forecast for that status.n”);
if (retval == 1)
printf(“It is cloudy with a high chance of rain.n”);
else if (retval == 2)
printf(“It is partly cloudy and windy.n”);
else if (retval == 3)
printf(“It is partly sunny with low humidity.n”);
else if (retval == 4)
printf(“It is warm and sunny with medium winds.n”);
else
printf(“It’s a perfect beach day. Sunny and hot!n”);

return retval; // Return this status value.
}

// Pre-condition: weather is an integer in between 1 and 5, inclusive,
// standing for the weather status for the day. cost is
// the cost of a cup of lemonade in cents for that day.
// Post-condition: The number of cups of lemonade for that day is returned.
int num_cups_sold(int weather, int cost) {

int optimal_price, max_cups;
double max_income;

// Calculate a maximum revenue for the day.
max_income = 5 + 3*weather;
optimal_price = 15 + 5*weather;
max_income = max_income – fabs(optimal_price – cost)/1.5;

// If it’s lower than 5 dollars, reset it to 5 dollars.
if (max_income < 5)
max_income = 5;

// From this, determine the maximum number of cups that could be sold.
max_cups = (int)(max_income/((double)cost/100));

// Return a random number from 0 to this maximum.
return rand()%(max_cups+1);

}

// Pre-condition: cash is the amount of cash the user has, num_lemons is
// the number of bags of lemons the user has left, num_sugar
// is the number of bags of sugar the user has left, and day
// is which day of the game just finished.
// Post-condition: A status report with the four values passed in is nicely
// displayed for the user.
//
// What to do with this function: This is fairly self-explanatory from the
// pre and post conditions. Look to the sample given in the assignment for
// the format.
void status_report(double cash, double num_lemons, double num_sugar, int day) {

}

// Pre-condition: pMoney, pLemons and pSugar are pointers to the variables
// storing the user’s amount of cash, number of bags of
// lemons and number of bags of sugar.
// Post-condition: A day’s transactions will take place and the amount of
// money, the number of bags of lemons and sugar will be
// adjusted accordingly.
//
// What to do with this function: First prompt the user with the weather
// report. Then, ask the user for how much they want to sell a cup of
// lemonade. Determine the number of cups that actually get sold for the
// day by determining how many cups the user COULD sell based on the
// availability of supplies and how many cups they COULD sell based on the
// weather. Print out how many cups of lemonade they ended up selling.
// Then adjust the amount of money they have, as well as the number of bags
// of lemons and sugar.

void sell_cups(double *pMoney, double *pLemons, double *pSugar) {

}

// Pre-condition: num_lemons is the number of bags of lemons the user has,
// and num_sugar is the number of bags of sugar they have.
// Post-condition: The function returns the maximum number of cups of
// lemonade the user can sell based on available supplies.
//
// What to do with this function: Calculate how many full cups of lemonade
// you can supply with sugar. Do the same calculation for lemons. Then,
// return the smaller of these two values.

int max_sell(double num_lemons, double num_sugar) {

}

// Pre-condition: None.
// Post-condition: Returns the number of cents the user will sell a cup of
// lemonade for, for that day.
//
// What to do with this function: Prompt the user to enter how much they
// want to charge for a cup of lemonade. If they don’t enter a positive
// integer, reprompt them until they do. Then return this value.

int get_cost() {

}

// Pre-condition: money is the amount of money the user has left at the end
// of the 10 days of running their Lemonade Stand.
// Post-condition: The user’s overall loss or profit is printed out.

// What to do with this function: See if what they have left is less than
// what they started with. If so, print out how much the lost. If it’s equal
// just print out a message saying that they broke even. Otherwise, print
// out how much profit they made!

void end_message(double money) {

}

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

Mysql Php Pagination Fix

March 29th, 2009 Comments off

Hello,

I have a script, it displays all active banners using pagination. Once the banner is clicked it doesn’t show up again. This works fine.

The issue:

For example I’m displaying 25 banners per page, I have over 1000 active banners so there are 102 pages.

If I click on the all 25 of the banners on page one and then leave the site, the next time I come back to the site they do not show. This works correctly. But here is the problem, when I come back to the site page one is blank, I have to move on to page 2 in order to see the next round of banners. So in other words it’s not moving the banners up to page one.

I need this fixed.

Here is the code if you think you want to tackle it.

[code]
<?php

session_start();

include "../header.php";

include "../config.php";

include "../style.php";
$uname=$_SESSION[uname];
if( session_is_registered("ulogin") ) {

$tbl_name="banners"; //your table name

// How many adjacent pages should be shown on each side?

$adjacents = 3;

/*

First get total number of rows in data table.

If you have a WHERE clause in your query, make sure you mirror it here.

*/

if( session_is_registered("ulogin") )

{

$query = "SELECT COUNT(*) as num FROM banners, banner_clicks WHERE banners.status=1 and banners.max>banners.shown AND banner_clicks.userid<>'".userid."' group by banners.id";

}

else

$query = "SELECT COUNT(*) as num FROM $tbl_name WHERE status=1 and max>shown";

$ttlpag=mysql_query($query) or die (mysql_error());

$total_pages = mysql_fetch_array($ttlpag);

$total_pages = $total_pages[num];
$qn="select * from sat_banclicks where userid='$uname' group by bannerid";
$ns=mysql_query($qn);
$nk=mysql_num_rows($ns);
$total_pages=$total_pages-(2*$nk);
//echo $nk;

/* Setup vars for query. */

$targetpage = "bannerlinkview.php"; //your file name (the name of this file)

$limit = 25; //how many items to show per page

$page = $_GET['page'];

if($page)

$start = ($page - 1) * $limit; //first item to display on this page

else

$start = 1; //if no page var is given, set start to 0

/* Get data. */

if( session_is_registered("ulogin") )

{

$sql = "SELECT banners.id as id, banners.name as name, banners.bannerurl as bannerurl, banners.targeturl as targeturl, banners.userid as userid, banners.shown as shown, banners.clicks as clicks, banners.max as max, banners.added as added FROM banners, banner_clicks WHERE banners.status=1 and banners.max>banners.shown AND banner_clicks.userid<>'".userid."' group by banners.id LIMIT $start, $limit";

}

else

{

$sql = "SELECT * FROM banners WHERE status=1 and max>shown LIMIT $start, $limit";

}

$result = mysql_query($sql) or die (mysql_error());

if(!mysql_num_rows($result))

{

$result = mysql_query ("SELECT * FROM banners WHERE status=1 and max>shown LIMIT $start, $limit");

}

/* Setup page vars for display. */

if ($page == 0) $page = 1; //if no page var is given, default to 1.

$prev = $page - 1; //previous page is page - 1

$next = $page + 1; //next page is page + 1

$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.

$lpm1 = $lastpage - 1; //last page minus 1

/*

Now we apply our rules and draw the pagination object.

We're actually saving the code to a variable in case we want to draw it more than once.

*/

$pagination = "";

if($lastpage > 1)

{

$pagination .= "<div class="pagination">";

//previous button

if ($page > 1)

$pagination.= "<a href="$targetpage?page=$prev">

Categories: MySQL, PHP Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Bear