Respuesta :
For the program a program that returns the total fee for both families and with the requirement method we will use Java.
The code in Java is,
import java.util.Scanner;
public class PriceFamily{
static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
outputPrice();
}
private static void outputPrice() {
int totFamilies;
double famprice = 0.0, totals = 0.0;
System.out.print("Enter no of families :");
totFamilies = scan.nextInt();
for (int i = 0; i < totFamilies; i++) {
System.out.println("Family#" + (i + 1) + ":");
famprice = getFamilyPrice();
famprice =addTax(famprice);
totals+=famprice;
}
System.out.printf("The total price of all Families :$%.2f",totals);
}
private static double addTax(double famprice) {
return famprice+(famprice*(9.75/100));
}
private static double getFamilyPrice() {
int totMembers, age;
double total = 0.0, price = 0.0;
System.out.print("How many members in the Family :");
totMembers = scan.nextInt();
for (int i = 0; i < totMembers; i++) {
System.out.print("Enter age Family member#" + (i + 1) + ":");
age = sc.nextInt();
if (age >= 2 && age <= 18) {
price = 10.10;
} else if (age >= 19 && age <= 55) {
price = 8.15;
} else if (age >= 56) {
price = 6.30;
}
total += price;
}
return total;
}
}
The class getFamilyPrice() is to get the total family price before the tax.
The class addTax(double famprice) is to calculate the total family price with tax.
The class outputPrice() is to display the total family price after tax.
Learn more about Java here:
brainly.com/question/18554491
#SPJ4