The jackpot of a lottery is paid in 20 annual installments. There is also a cash option, which pays the winner 65% of the jackpot instantly. In either case 30% of the winnings will be withheld for tax. Design a program to do the following. Ask the user to enter the jackpot amount. Calculate and display how much money the winner will receive annually before tax and after tax if annual installments is chosen. Also calculate and display how much money the winner will receive instantly before and after tax if cash option is chosen. GRADING RUBRIC FOR EACH PROBLEM

Respuesta :

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