Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

THIS HAS 2 PARTS 1) Write an application that prompts a user for a child’s curre

ID: 3809762 • Letter: T

Question

THIS HAS 2 PARTS

1)

Write an application that prompts a user for a child’s current age and the estimated college costs for that child at age 18.

Continue to reprompt a user who enters an age value greater than 18.

Display the amount that the user needs to save each year until the child turns 18, assuming that no interest is earned on the money.

Assume that integer division provides a sufficient answer.

Save the file as CollegeCost.java.

2)

Create the application/project CollegeCostTest.java class containing the main method and an object to use the CollegeCost class.

Explanation / Answer

Hi, Please find my implementation.

import java.util.Scanner;

public class CollegeCost {

  

   public static void main(String[] args) {

      

       Scanner sc = new Scanner(System.in);

      

       System.out.print("Enter estimated college costs for that child: ");

       int cost = sc.nextInt();

      

       System.out.print("Enter child current age: ");

       int age = sc.nextInt();

      

       while(age < 18){

          

           int cost_year = cost/(18-age);

          

           System.out.println(cost_year+ " need to save per year");

           System.out.print("Enter child current age: ");

           age = sc.nextInt();

       }

   }

}

/*

Sample run:

Enter estimated college costs for that child: 32345

Enter child current age: 12

5390 need to save per year

Enter child current age: 11

4620 need to save per year

Enter child current age: 13

6469 need to save per year

Enter child current age: 18

*/