Question
We will create aPrice calculator. The user will type a Price(a number more than 0) and enter number of units (a number more than or
We will create aPrice calculator. The user will type a Price(a number more than 0) and enter number of units (a number more than or equal to 1) then click the total button. The Total"so far" is displayed to the screen. The user may repeat the process, to add more units and prices, repeatedly till they either Quit the application or hit the Reset button. Complete the following to accomplish this outcome:
Write code so when the user hits Total, the code:
gets the value from a Pricetxttextbox and assigns it to a variable named PriceSngusing the Csngconversion. Ask questions in the Discussion if you do not know how to do this.
the code then checks that PriceSng is > 0, if not issue an error message"Enter positive numbersonly".None of conditions or actions below should execute. Do not use Exit or Return statements. Use Elseif for code behaviorto happen.
If the above check passes, then check that UnitsIntis more than or equal to 1, otherwiseshow an error message "Units must be more than 1". Again,None of conditions or actions below should execute. Do not use Exit or Return statements. Use Elseif for code behaviorto happen.
The logic to calculate the accumulated Totalis this: Create a global variable TotalSngin a Single type, and assign it to 0.0. Under the Totalbutton, use this formula: x + (PriceSng*UnitsInt*(1+TaxRate) where x is the current Total, PriceSng is the current price and UnitsInt is the number of items of that price, and TaxRate is a constant assigned to the TaxRate in Los Angels represented as fraction, e.g. 0.09.
All messages shown must usemessagebox.show, and nothing else.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started