Jenevic PHP

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 6

<?

php
$sales = [
[
"sales_id" => 1,
"buyer" => "Ace",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 2,
"buyer" => "George",
"item" => (object) [
"name" => "Milk Shake",
"quantity" => 8,
"price" => 80
]
],
[
"sales_id" => 2,
"buyer" => "Jap",
"item" => (object) [
"name" => "Pizza",
"quantity" => 2,
"price" => 300
]
],
[
"sales_id" => 4,
"buyer" => "Wayne",
"item" => (object) [
"name" => "Turks",
"quantity" => 2,
"price" => 80
]
],
[
"sales_id" => 5,
"buyer" => "Luffy",
"item" => (object) [
"name" => "Meat",
"quantity" => 100,
"price" => 500
]
],
[
"sales_id" => 5,
"buyer" => "Zoro",
"item" => (object) [
"name" => "Beer",
"quantity" => 10,
"price" => 120
]
],
[
"sales_id" => 5,
"buyer" => "Sanji",
"item" => (object) [
"name" => "Soup",
"quantity" => 3,
"price" => 60
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
[
"sales_id" => 5,
"buyer" => "Character 1",
"item" => (object) [
"name" => "Buko Shake",
"quantity" => 5,
"price" => 50
]
],
];

// Activity 1: Simple Point of Sale Application (10 Points Each)

// Item 1 - Output the name of the item Wayne bought.

echo $sales [0] -> item ["name"];


echo "<br>";

// Item 2 - Output the name, quantity, and price of the item Jap bought.
echo $sales ->item ["name"];
echo "<br>";
echo $sales ->item ["quantity"];
echo "<br>";
echo $sales ->item ["price"];

// Item 3 - Calculate the total sales of the store.

$total_sales = 0;
for ($i = 0; $i < count ($sales); $i++) {
$total_sales += $sales[$i]->item['price'] * $sales[$i]->item['quantity'];
}
echo "Total Sales:" . $total_sales;
/
?>

You might also like