asked 165k views
4 votes
In java - compute the average kids per family. note that the integers should be type cast to doubles.

asked
User ChiakiYu
by
8.6k points

1 Answer

3 votes

Answer:

import java.util.Scanner;

public class TypeCasting {

public static void main(String[] args) {

Scanner scnr = new Scanner(System.in);

int numKidsA;

int numKidsB;

int numKidsC;

int numFamilies;

double avgKids;

numKidsA = scnr.nextInt();

numKidsB = scnr.nextInt();

numKidsC = scnr.nextInt();

numFamilies = scnr.nextInt();

avgKids = (double) (numKidsA + numKidsB + numKidsC) / numFamilies;

System.out.println(avgKids);

}

}

Step-by-step explanation:

No related questions found

Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.