Question

In JAVA, given two integer variables petsPerFamily and noOfFamilies, declare an avgPets variable and write a...

In JAVA, given two integer variables petsPerFamily and noOfFamilies, declare an avgPets variable and write a statement that calculates the average number of pets per family so that a fractional average is produced.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Statement that calculates the average number of pets per family so that a fractional average is produced
 
double avgPets = (petsPerFamily + noOfFamilies)/2.0;

Answer :
double avgPets = (petsPerFamily + noOfFamilies)/2.0;
Add a comment
Know the answer?
Add Answer to:
In JAVA, given two integer variables petsPerFamily and noOfFamilies, declare an avgPets variable and write a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 8) Write the Java code to Declare an Integer Number and Initialize it to value 10....

    8) Write the Java code to Declare an Integer Number and Initialize it to value 10. Then use Ternary Operator to Check if the Integer Number is Odd or Even and print out the Result Odd or Even.

  • Write a Java program that uses six grades as integer values and calculate their average. Result...

    Write a Java program that uses six grades as integer values and calculate their average. Result must be printed as a floating data type. Design your program using the following specifications. 1. You must declare integer variables to hold the grades. Assume grades are always integer. 2. Result must be stored in a separate variable. 3. All numbers in the output must be in floating data type. 4. All grades must be displayed in one significant digit floating number. 5....

  • I need help with this. Can someone please show me the solution. Declaring and Initializing Java...

    I need help with this. Can someone please show me the solution. Declaring and Initializing Java Variables Summary In this lab, you declare and initialize variables in a Java program. The program file named NewAge.java, calculates your age in the year 2050. Instructions Declare an integer variable named newAge. Declare and initialize an integer variable named currentAge. Initialize this variable with your current age. Declare and initialize an integer variable named currentYear. Initialize this variable with the value of the...

  • Write a Java program that does the following. a. Declare an integer 2D array with 5...

    Write a Java program that does the following. a. Declare an integer 2D array with 5 rows and 5 columns. b. Initialize the array's elements to random integers between 1 and 10 (inclusive). c. Display all the elements in the 2D array as a table of rows and columns. d. Display the row index and column index of all the even integers in the 2D array. e. Display the sum of first row's elements.

  • 1. declare two integer variables x and y and two pointers to p and q. initialize...

    1. declare two integer variables x and y and two pointers to p and q. initialize the value of x with 2, y with 8 and the pointer p should point to the address of x and q should point to the address of y. 2. then write a C statements that will print the following information: a. the address of x and the value of y. b. the value of p and the value of *p. c. the address...

  • Write a C program that will do the following: 1.Declare four integers variables.   intVar1, intVar2, intVar3,and...

    Write a C program that will do the following: 1.Declare four integers variables.   intVar1, intVar2, intVar3,and intVar4. 2. Initialize intVar1 to the value 4; initialize intVar2to the value 5. 3. Declare four more integer variables. exp1, exp2,exp3, and exp4. 4. Declare a character variable charVar. 5. Assign the value of each expression below to variables exp1and exp2 respectively: exp1= intVar1 + ((5 * intVar2) / (3 * intVar1)); exp2 = intVar1 + (5 * (intVar2 / 3)) * intVar1; 6....

  • Java program 5. Write a short Java program to compute factorial of a given integer from...

    Java program 5. Write a short Java program to compute factorial of a given integer from input using recursive function.

  • Question 1 When you declare a variable of type Single, it contains 0 by default. True...

    Question 1 When you declare a variable of type Single, it contains 0 by default. True False Question 2 The following line declares an array that can contain whole numbers, with 10 elements. Dim Variables(9) As Integer True False Question 3 Once a variable is declared we can not change the variable's data type. True False Question 4 If A is False and B is True, then A Or B is True because A is False. True False Question 5...

  • Java - Object Oriented Programming Declare a class named Customer that has two private fields? Write...

    Java - Object Oriented Programming Declare a class named Customer that has two private fields? Write a set method to make sure that if age > 125 years or less than 0 then it is set to 0 (default value) What does it indicate when declaring a class's instance variables with private access modifier? What is the role of a constructor? The data part of by an object's instance variables is known as? Do all methods have to always return...

  • Evaluate Exponent: Declare a double variable called result and initialize it to 1.0; Ask the user...

    Evaluate Exponent: Declare a double variable called result and initialize it to 1.0; Ask the user for two values - one for the base, and the other for the exponent. If the exponent parameter is 0, give the user an error. You do not need to handle a negative exponent value. Otherwise, declare an integer variable called loop and initialize it to 0 Write a do while loop as follows: Inside the loop: Multiply the results times the number Increment...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT