Log in

View Full Version : running my program displays none of my stdin or prints



Legato213
11-04-2008, 01:34 AM
writing a homework assignment for some car dealership thing and when i run the program the dos window comes up blank. i dont understand why!



<?php
$disco = array();
$sticker = 0;
$year = 0;
$code = 0;
$row = 0;
$col = 0;
$percent = 0.0;

$fb = fopen("discount.txt", 'r') or die("\n Can not find file discount.txt\n");

$r = 0;
while( $r <6)
{
fscanf($fb,"%f%f%f%f%f", $disco[$r][0],$disco[$r][1],$disco[$r][2],$disco[$r][3],$disco[$r][4]);
$r = $r + 1;
}
fscanf(STDIN, "%d", $sticker);
fscanf(STDIN, "%d", $year);
fscanf(STDIN, "%d", $code);
$row = 2006 - $year;
$col = $code - 1;
$discoPercent = $disco[$row][$col];
$percent = $col * 100;
$discountAmount = $col * $sticker;
$salePrice = $sticker - $discountAmount;
print("\nSticker price: $sticker");
print("\nDiscount: $percent %");
print("\nDiscount amount: %discountAmount");
print("\nSales prices: $salePrice");
fclose($fb);

?>




my data file:

0.050 0.055 0.060 0.065 0.070
0.040 0.045 0.050 0.055 0.060
0.030 0.035 0.040 0.045 0.050
0.020 0.025 0.030 0.035 0.040
0.010 0.015 0.020 0.025 0.030
0.005 0.010 0.015 0.020 0.025

magicyte
11-04-2008, 01:37 AM
Wait... You're doing this in PHP?? Why is there a DOS window involved?! If you could explain more of it, I'd be happy to answer. The functions you use remind me of C/C++...

-magicyte

Legato213
11-04-2008, 01:42 AM
when i run the program its supposed to display to the screen instead of a file. so it runs it in the /cmd window. but it comes up blank not quite sure how else to explain it.

magicyte
11-04-2008, 02:00 AM
Oh. Understood. Well, I don't know why... Could you give me your whole data file in a [ CODE ] [ / CODE ] thing?

-magicyte

Legato213
11-04-2008, 02:06 AM
its just a .txt file ext


0.050 0.055 0.060 0.065 0.070
0.040 0.045 0.050 0.055 0.060
0.030 0.035 0.040 0.045 0.050
0.020 0.025 0.030 0.035 0.040
0.010 0.015 0.020 0.025 0.030
0.005 0.010 0.015 0.020 0.025

Legato213
11-04-2008, 02:21 AM
hahahahahahah wow i figured it out. gosh do i feel dumb haha i didnt have a prompt for my STDIN's lol