Trusted by Students Everywhere
Why Choose Us?
0% AI Guarantee

Human-written only.

24/7 Support

Anytime, anywhere.

Plagiarism Free

100% Original.

Expert Tutors

Masters & PhDs.

100% Confidential

Your privacy matters.

On-Time Delivery

Never miss a deadline.

Compute the average kids per family

Computer Science Dec 29, 2020

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

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 per family: "); System.out.println(avgKids); return; } }

i can't figure it out

Expert Solution

TypeCasting.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("Average kids per family: ");

System.out.println(avgKids);

return;

}

}

Output:

Average kids per family: 3.3333333333333335

Archived Solution
Unlocked Solution

You have full access to this solution. To save a copy with all formatting and attachments, use the button below.

Already a member? Sign In
Important Note: This solution is from our archive and has been purchased by others. Submitting it as-is may trigger plagiarism detection. Use it for reference only.

For ready-to-submit work, please order a fresh solution below.

Or get 100% fresh solution
Get Custom Quote
Secure Payment