Compute the average kids per family. Note that the integers should be type cast to doubles.

Compute the average kids per family. Note that the integers should be type cast to doubles.

Calculate the average number of kids per family. Note that the integers should be type cast to doubles. Calculate the average number of children per family. Be sure to type cast the integers to doubles.

Average Kids Per Family

import java.util.Scanner;
public class TypeCasting {
public static void main (String [] args)
{
int numKidsA = 1;
int numKidsB = 4;
int numKidsC = 5;
int numFamilies = 3;
double avgKids = 0.0;
System.out.print(“Average kids: “);
System.out.println(avgKids);
return;
}
}

"Compute

Answer

Type Casting.java
import java.util.Scanner;
public class TypeCasting {
public static void main(String[] args) {
int numKidsA = 1;
int numKidsB = 4;
int numKidsC = 5;
int numFamilies = 3;
double avgKids = 0.0;
avgKids = (numKidsA + numKidsB + numKidsC) /(double)numFamilies;
System.out.print(“kids per family: “);
System.out.println(avgKids);
return;
}
}

Read Also

How many twisted teas can get me drunk?

See also  what does being J-boarded in a greek organization mean?