#!/usr/bin/perl -w use strict; #cash register and print receipt program my (@items, %qty, %price); #User input here print "Please enter your first and last name\n"; chomp (my $name = ); print "Please enter your state sales tax in percentage (i.e. 7.75)\n"; chomp (my $tax = ); my $taxrate = $tax / 100; # enter loop to capture customer information here my $continue='Y'; while ($continue eq 'Y'){ print "Please enter an item or product name\n"; chomp (my $itemname = ); push @items, $itemname; print "Please enter the quantity of the item\n"; chomp (my $itemquantity = ); $qty{$itemname} = $itemquantity; print "Please enter the price of the item (no \$ please)\n"; chomp (my $itemprice = ); $price{$itemname} = $itemprice; print "Would you like to add another item? - Y or N\n"; chomp ($continue = ); } # process subtotal and print receipt output here my $subtotal; foreach my $item (@items) { print "Item: $item\n"; #$q_item = $qty{$item}; print "Quantity: $qty{$item}\n"; #$p_item = $price{$item}; print "Price: \$$price{$item}\n"; my $itemtotal = $qty{$item} * $price{$item}; print "Item total: \$$itemtotal\n"; $subtotal += $itemtotal; print "Your current subtotal is: \$$subtotal\n"; } #print totals and tax here print "Purchase Subtotal: $subtotal\n"; print "Sales Tax Rate: $tax\n"; my $totaltax = $subtotal * $taxrate; print "Total Sales Tax = \$$totaltax\n"; my $totalamount = $subtotal + $totaltax; print "The total amount of this sale is: \$$totalamount\n"; #print the customer name and current date and time print "\n"; print "Customer: $name\n"; print "\n"; my $now = localtime time; print "Current Date and Time: $now\n"; #### print "Would you like to add another item? - Y or N\n"; chomp ($continue = ); #### $continue = some invalid value; while ($continue is not a valid value) { print out the prompt; chomp ($continue = ); # unchanged. }