Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $arr=explode("|",readline());
- $budget=readline();
- $j=0;
- $profit=0;
- $initialbudget=$budget;
- $prices=[];
- while($j<count($arr))
- {
- $products=explode("->",$arr[$j]);
- switch ($products[0])
- {
- case "Clothes":
- if($products[1]>50);
- else {
- if ($budget - $products[1] >= 0) {
- $budget -= $products[1];
- $profit += 1.4 * $products[1];
- $prices[] = 1.4 * $products[1];
- }
- }
- break;
- case "Shoes":
- if($products[1]>35) ;
- else
- {
- if($budget-$products[1] >= 0)
- {
- $budget-=$products[1];
- $profit+=1.4*$products[1];
- $prices[]=1.4*$products[1];
- }
- }
- break;
- case "Accessories":
- if($products[1]>20.5);
- else {
- if ($budget - $products[1] >= 0) {
- $budget -= $products[1];
- $profit += 1.4 * $products[1];
- $prices[] = 1.4 * $products[1];
- }
- }
- break;
- default:
- $budget-=$products[1];
- break;
- }
- if($budget<0) $budget+=$products[1];
- $j++;
- }
- for($i=0;$i<count($prices);$i++)
- {
- printf("%.2f ",$prices[$i]);
- }
- echo "\n";
- printf("Profit: %.2f\n",$profit+$budget-$initialbudget);
- if($profit+$budget>=150) echo "Hello, France!".PHP_EOL;
- else echo "Time to go.".PHP_EOL;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement