Question

In: Computer Science

Do not use import java.util.Scanner; Working in the Financial Aid Office you have been asked to...

Do not use import java.util.Scanner;

Working in the Financial Aid Office you have been asked to create a program that calculates the amount of financial aid a family is eligible for, based on the number of dependents in the household. The business rules for determining eligibility are as follows:

  • If there are 2 dependents in the household the family is eligible for $1,500 per dependent
  • If there are 3 dependents in the household the family is eligible for $2,500 per dependent
  • If there are 4 dependents in the household the family is eligible for $3,000 per dependent
  • In all other situtations, the family is not eligible for any financial aid

You can use the following stub solution. Copy and paste this solution into your IDE. You should complete blocks 1 through 4.

import javax.swing.JOptionPane;

public class FinancialAid {
   public static void main(String[] args) {
      final int NUM_MIN_DEPENDENTS = 0;
      final int NUM_MAX_DEPENDENTS = 9;
     
      /* #1: Create code that will call the method you created in #3 below to get the number of dependents,
       *     factoring in the minimum and maximum number of dependents allowed
       */

     
      /* #2: Create code that will call the method you created in #4 below to calculate the amount of aid
       *     that will be earned based on the number of dependents gathered.
       */


      printFinancialAid(aid);
   }
  
   /* #3: Create a method to get and return the number of dependents, factoring in
    *     the minimum and maximum number of dependents allowed
    */

  
   /* #4: Create a method to calculate and return the amount of financial aid that will be earned
    *      based on the number of dependents gathered
    */
   

   public static void printFinancialAid(double aid) {
      JOptionPane.showMessageDialog(null, "The amount of financial aid your family is eligible for is: $" + String.format("%.2f", aid));
   }
}

Solutions

Expert Solution

JAVA PROGRAM:

import javax.swing.JOptionPane;

public class Test {

    public static void main(String[] args) {

        final int NUM_MIN_DEPENDENTS = 0;

        final int NUM_MAX_DEPENDENTS = 9;

        /** #1: Create code that will call the method you created in

         *  #3 below to get the number of dependents,

         *  factoring in the minimum and maximum number of dependents allowed

         * */

        int num = getNumberOfDependents();

        /* check enter number of dependents between 0-9*/

        while(num<NUM_MIN_DEPENDENTS || num>NUM_MAX_DEPENDENTS){

            // if num out range btween 0-9 then ask again

            num = getNumberOfDependents();

        }

        /** #2: Create code that will call the method you created in #4 below to calculate the amount of aid

         *  that will be earned based on the number of dependents gathered.*/

        double aid = calculateAmount(num);

        printFinancialAid(aid);  

    }

    /** #3: Create a method to get and return the number of dependents, factoring in

     * the minimum and maximum number of dependents allowed */

    public static int getNumberOfDependents() {

         // show the dialog box for input

         String input = JOptionPane.showInputDialog("Enter the number of dependents:");

         int num = Integer.parseInt(input);// convert string to int

         return num;

    }  

    /** #4: Create a method to calculate and return the amount of financial aid that will be earned

     * based on the number of dependents gathered */

    public static double calculateAmount(int num) {

        // Declare variable amount

        double amount = 0;

        // If there are 2 dependents in the household the family is eligible for $1,500 per dependent

        if(num==2){

            amount = num * 1500;

        //If there are 3 dependents in the household the family is eligible for $2,500 per dependent

        }else if(num==3){

            amount = num * 2500;

       //If there are 4 dependents in the household the family is eligible for $3,000 per dependent

        }else if(num==4){

            amount = num * 3000;

        // In all other situtations, the family is not eligible for any financial aid

        }else{

            amount=0;

        }

        return amount;

   }   

   public static void printFinancialAid(double aid) {

        JOptionPane.showMessageDialog(null, "The amount of financial aid your family is eligible for is: $" + String.format("%.2f", aid));

   }

}

OUTPUT:

NOTE: If you don't understand any step please let me know at once.


Related Solutions

import java.util.Random; import java.util.Scanner; public class Compass { // You will need to do the following:...
import java.util.Random; import java.util.Scanner; public class Compass { // You will need to do the following: // // 1.) Define a private instance variable which can // hold a reference to a Random object. // // 2.) Define a constructor which takes a seed value. // This seed will be used to initialize the // aforementioned Random instance variable. // // 3.) Define a static method named numberToDirection // which takes a direction number and returns a String // representing...
You are the nurse working in a cancer center. You have been asked to take a...
You are the nurse working in a cancer center. You have been asked to take a position to help counsel patients about their choices once they are diagnosed with cancer. Your position is not to persuade them one way or the other, but rather to give them the factual information regarding their choices, provide resources to them, and be there for any support.   provide feedback on areas that you will identify as important to make the patient aware of when...
You are working for an investment firm in the City of London and have been asked...
You are working for an investment firm in the City of London and have been asked to perform some analysis of the European-style call options of a company called Elevation Matters Plc (EM). The most recent closing share price for EM was £38. The risk-free rate is 3%. The time to expiry for the options is one year. The volatility (standard deviation) of EM’s shares is 25% and the company has decided not to pay any dividends this year. On...
JAVA ONLY - Complete the code import java.util.Scanner; /** * This program will use the HouseListing...
JAVA ONLY - Complete the code import java.util.Scanner; /** * This program will use the HouseListing class and display a list of * houses sorted by the house's listing number * * Complete the code below the numbered comments, 1 - 4. DO NOT CHANGE the * pre-written code * @author * */ public class HouseListingDemo { public static void main(String[] args) { Scanner scan = new Scanner(System.in); HouseListing[] list; String listNumber, listDesc; int count = 0; double listPrice; String...
You have been asked by the Payroll Manager, Linda Laporte, to create a short job aid...
You have been asked by the Payroll Manager, Linda Laporte, to create a short job aid to assist the payroll practitioners with reconciling the Revenu Québec (RQ) account. Your organization is a monthly remitter. In your own words, outline suggested reconciliation methods including the forms, tools and reports that would be used in the process.
You are an experienced, certified nurse working in an endoscopy lab. You have been asked to...
You are an experienced, certified nurse working in an endoscopy lab. You have been asked to prepare a presentation for staff education days at your facility. Select a digestive disorder for this discussion and, if necessary, research the clinical manifestations of the disorder. Describe the alterations in digestive functioning associated with the disorder you have chosen. Be sure to present it in a format that is appropriate for the type of presentation you are giving and to the audience you...
Since you are working on your MBA you have been asked to speak to the board...
Since you are working on your MBA you have been asked to speak to the board of directors of your firm about various methods of analyzing the companies financial statements. One of the board members states she has heard about a technique called"common-size" financial statements, but knows nothing about it. She would like you to explain what they are, how they are prepared,how they differ from regular financial statements, and how they can help the board in its decision making....
Can you fix the errors in this code? package demo; /** * * */ import java.util.Scanner;...
Can you fix the errors in this code? package demo; /** * * */ import java.util.Scanner; public class Booolean0p {        public class BooleanOp {            public static void main(String[] args) {                int a = 0, b = 0 , c = 0;                Scanner kbd = new Scanner(System.in);                System.out.print("Input the first number: ");                a = kbd.nextInt();                System.out.print("Input...
import java.util.Scanner; public class MonthsOnAndAfter { // You will need to write a method that makes...
import java.util.Scanner; public class MonthsOnAndAfter { // You will need to write a method that makes this // code compile and produce the correct output. // YOU MUST USE switch! // As a hint, you should not have to use the name of each // month more than once. // TODO - write your code below this comment. // DO NOT MODIFY main! public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter month (0-11): "); int month...
import java.util.Scanner; public class Months { // You will need to write a method that makes...
import java.util.Scanner; public class Months { // You will need to write a method that makes this // code compile and produce the correct output. // YOU MUST USE switch! // TODO - write your code below this comment. // DO NOT MODIFY main! public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter month (0-11): "); int month = input.nextInt(); String output = monthAsString(month); System.out.println(output); } }
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT