Asked by alhaji

Write a program that will emulate a cash register. Ask the user to input the price of three items. Get a subtotal. Determine the tax (6% ) of the subtotal. Find the total amount of the sale subtotal plus tax. Display the price of each item, subtotal amount, tax amount and final amount.

Answers

Answered by Steve
maybe you can work with this as a model


@p = ();
$st = 0;

for ($i=1 ; $i <= 3 ; $i++) {
print "Price of item #$i: ";
$v = <STDIN>; chomp $v;
$p[$i] = $v;
$st += $v;
}
$tax = $st * 0.06;
$total = $st + $tax;
print "\nItem Price\n";
for ($i=1 ; $i <= 3 ; $i++) {
printf "%4d %12.2f\n",$i,$p[$i];
}
printf "%s\n","-"x17;
printf "subtotal: %7.2f\ntax: %12.2f\ntotal: %10.2f\n",$st,$tax,$total


sample run:


perl jiskha1.pl
Price of item #1: 1763.2
Price of item #2: .85
Price of item #3: 12

Item Price
1 1763.20
2 0.85
3 12.00
-----------------
subtotal: 1776.05
tax: 106.56
total: 1882.61
There are no AI answers yet. The ability to request AI answers is coming soon!

Related Questions