Question: Write a program that calculates the product's price after adding the VAT. This program will prompt the user to enter the price before adding the

Write a program that calculates the product's price after adding the VAT. This program will prompt the user to enter the price before adding the VAT and the VAT rate. Then it will display the VAT inclusive price. If the price that entered by the user is a negative number or the VAT rate is less than 0 or greater than 100, this program should throw an exception. You should apply the following: Define a VATincPrice method to calculate the VAT inclusive price. This method takes the price and the VAT rate as arguments. If the price is greater than or equal to zero and the VAT rate is between 0 and 100, this method will calculate the VAT inclusive price using the formula : VAT inclusive price = (VAT rate *price)+price Otherwise, it will throw (VATincPriceException) exception with the VAT rate should be between 1 and 100 and the price should be greater than 0 as an error message. Declare a user-defined exception class (VATincPriceException) with appropriate constructor. In the main method: o Prompt the user to enter the price before adding the VAT and the VAT rate. o Calculate VAT inclusive price by calling a VATincPrice method. o Print the VAT inclusive price. o Handle the VATincPriceException that might be thrown and print the stack trace for this exception. o Handle the exceptions that might be thrown in the main method.  Write a program that calculates the product's price after adding the

VAT. This program will prompt the user to enter the price before

Name: ID: Group: Group(1) Group(2) con una Exam Instructions: Save your program under your name (Example: LQuiz1_MahaAlali.Java). Submit the solution through Blackboard along with a backup copy (Word File). Also, copy and paste the solution to the Blackboard submission comments. Write a program that calculates the product's price after adding the VAT. This program will prompt the user to enter the price before adding the VAT and the VAT rate. Then it will display the VAT inclusive price. If the price that entered by the user is a negative number or the VAT rate is less than 0 or greater than 100, this program should throw an exception. You should apply the following: Define a VATinc Price method to calculate the VAT inclusive price. This method takes the price and the VAT rate as arguments. If the price is greater than or equal to zero and the VAT rate is between 0 and 100, this method will calculate the VAT inclusive price using the formula: VAT inclusive price - (VAT rate *price)tprice Otherwise, it will throw (VATinc PriceException) exception with the VAT rate should be between 1 and 100 and the price should be greater than 0" as an error message. Declare a user-defined exception class (VATinc PriceException) with appropriate constructor In the main method: Prompt the user to enter the price before adding the VAT and the VAT rate. Calculate VAT inclusive price by calling a VATincPrice method: o Print the VAT inclusive price. Handle the VATinc PriceException that might be thrown and print the stack trace for this exception Handle the exceptions that might be thrown in the main method. Samples of the run: The program alculate the product Det ding the VAT 111 T YAT VAT ato might be thrown and print the stack trace for this exception. Handle the exceptions that might be thrown in the main method. Samples of the run: TUD This program calculates the product.prico arter adding the VAT Enter the price before adding the VAT and the VAT rate : 15 Tho VAT inclusive price 140.25 BUILD SUCCESSFUL (total time: 12 seconds) TU: This program calculates the product's price after adding the VAT Enter the price before adding the VAT and the VAT rate : -100 5 1 addingvat.VATANPricexception the VAT rato should be between 1 and 100 and the price should b at addingvat. AddingVAT.VATinePrice (addingVAT.java:21) at addingvat. AddingVAT.main (AddingVAT.avat 30) This program calculates the products price after adding the VAT Enter the price before adding the VAT and the VAT rate 35 105 addingvat. VaTinePriceception the VAT rate silould be between 1 and 100 and the price should b at addingvat.adai NGVAT.VATIC Pico (addingVAT. Java 121) at addingvat. Ada UVAT.main(addingVAT. Java 130) LUN: This program calculates the product's price after adding the VAT Enter the price before adding the VAT and the VAT rate : 35 VAT Enter a valid value

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!