Question: Summary In this lab, you will complete a Java program that uses a two-dimensional array to store data for the Building Block Day Care Center.

Summary In this lab, you will complete a Java program that uses a two-dimensional array to store data for the Building Block Day Care Center. The day care center charges varying weekly rates depending on the age of the child and the number of days per week the child attends. The program should allow users to enter the age of the child and the number of days per week the child will be at the day care center. The program should output the appropriate weekly rate. The file provided for this lab contains all of the necessary variable declarations, except the two-dimensional array. You need to write the input statements and the code that initializes the two-dimensional array, determines the weekly rate, and prints the weekly rate. Comments in the code tell you where to write your statements. Weekly rates can be found in the provided table. Instructions Declare and initialize the two-dimensional array. Write the Java statements that retrieve the age of the child and the number of days the child will be at the day care center. Determine and print the weekly rate. Execute the program.

import java.util.Scanner;

public class DayCare

{

public static void main(String args[])

{

// Declare two-dimensional array here.

double rate[][] = {

{30, 60, 88, 115, 140},

{26, 52, 70, 96, 120},

{24, 46, 67, 86, 110},

{22, 40, 60, 75, 88},

{20, 35, 50, 66, 84}};

// Declare other variables.

int numDays;

int age;

String numDaysString;

String ageString;

int QUIT = 99;

Scanner input = new Scanner(System.in);

// This is the work done in the getReady() method

// Perform a priming read to get the age of the child.

System.out.println("Enter the child age or 99 to quit: ");

age = 0;

while(age != QUIT)

{

// This is the work done in the determineRateCharge() method

if(age > 4)

age =0;

// Ask the user to enter the number of days

System.out.println("Enter the number of days: ");

numDays = 0;

// Print the weekly rate

System.out.println("Weekly Rate is $" + rate[age][numDays-1]);

// Ask the user to enter the next child's age

System.out.println("Enter the next child's age or 99 to Quit: ");

}

// This is the work done in the finish() method

System.out.println("End of program");

System.exit(0);

} // End of main() method.

} // End of DayCare class.

I don't understand where the error is coming from,

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!