Answer:
// here is code in java.
import java.util.*;
// class defintion
class Main
{
// main method of the class
public static void main (String[] args) throws java.lang.Exception
{
try{
// scanner object to read input string
Scanner s=new Scanner(System.in);
// variables
double amount;
int ch;
double bef_tax, aft_tax;
System.out.print("Please enter the jackpot amount:");
// read the amount from user
amount=s.nextDouble();
System.out.print("enter Payment choice (1 for cash, 2 for installments): ");
// read the choice
ch=s.nextInt();
// if choice is cash then calculate amount before and after the tax
if(ch==1)
{
bef_tax=amount*.65;
aft_tax=(amount*.70)*.65;
System.out.println("instantly received amount before tax : "+bef_tax);
System.out.println("instantly received amount after tax : "+aft_tax);
}
// if choice is installment then calculate amount before and after the tax
else if(ch==2)
{
bef_tax=amount/20;
aft_tax=(amount*.70)/20;
System.out.println("installment amount before tax : "+bef_tax);
System.out.println("installment amount after tax : "+aft_tax);
}
}catch(Exception ex){
return;}
}
}
Explanation:
Read the jackpot amount from user.Next read the choice of Payment from user. If user's choice is cash then calculate 65% instantly amount received by user before and after the 30% tax.Print both the amount.Similarly if user's choice is installments then find 20 installments before and after 30% tax.Print the amount before and after the tax.
Output:
Please enter the jackpot amount:200
enter Payment choice (1 for cash, 2 for installments): 2
installment amount before tax : 10.0
installment amount after tax : 7.0