Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add a sales tax calculation of 8% based on the discounted price. Then, display the sales tax rate and the calculated sales tax amount after

"Add a sales tax calculation of 8% based on the discounted price. Then, display the sales tax rate and the calculated sales tax amount after the discounted price."

Please answer of this qustions with codes.

//MUST Complete code at line 35

//Calculate tax if exists

// get the data from the form

$product_description = filter_input(INPUT_POST, 'product_description');

$list_price = filter_input(INPUT_POST, 'list_price', FILTER_VALIDATE_FLOAT);

$discount_percent = filter_input(INPUT_POST, 'discount_percent', FILTER_VALIDATE_INT);

// validate data

if (empty($product_description)) {

$error_message = 'Product description is a required field.';

} else if ($list_price === FALSE) {

$error_message = 'List price must be a valid number.';

} else if ($list_price <= 0) {

$error_message = 'List price must be greater than 0.';

} else if ($discount_percent === FALSE) {

$error_message = 'Discount percent must be a valid whole number.';

} else if ($discount_percent <= 0) {

$error_message = 'Discount percent must be greater than 0.';

} else {

$error_message = '';

}

// if an error message exists, go to the index page

if ($error_message != '') {

include('index.php');

exit();

}

// calculate the discount

$discount = $list_price * $discount_percent * .01;

$discount_price = $list_price - $discount;

// calculate the sales tax

// apply currency formatting to the dollar and percent amounts

$list_price_formatted = "$".number_format($list_price, 2);

$discount_percent_formatted = $discount_percent."%";

$discount_formatted = "$".number_format($discount, 2);

$discount_price_formatted = "$".number_format($discount_price, 2);

//enable these two lines once you add the missing code

// $sales_tax_percent_formatted = $sales_tax_percent."%";

// $sales_tax_formatted = "$".number_format($sales_tax, 2);

?>

Product Discount Calculator

Product Discount Calculator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions

Question

=+What is the nature of their impact?

Answered: 1 week ago

Question

=+Is it possible to operate union-free?

Answered: 1 week ago

Question

=+impact member states and MNEs?

Answered: 1 week ago