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.
Statement that calculates the average number of pets per family so that a fractional average is produced double avgPets = (petsPerFamily + noOfFamilies)/2.0;
double avgPets = (petsPerFamily + noOfFamilies)/2.0;
In JAVA, given two integer variables petsPerFamily and noOfFamilies, declare an avgPets variable and write a...
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 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 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 to read a list of nonnegative integers and to display the largest integer, the smallest integer and the average of all the integers. The user indicates the end of the input by entering a negative sentinel value that is not used in finding the largest, smallest and average values. The average should be a value of type double so that it is computed a fractional part. * Java program free from syntax, logic and run time...
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.
Write a java class that obtains an integer value from a customer that represents the number of photocopies to be printed. Then, calculate and display the total job cost. Your "if" test will determine whether or not there are more than 50 copies involved. You will need to use the DecimalFormat class to obtain the proper number of decimal places shown in the output sample. Review Notes 3. Base your calculations on these rates: the cost for up to and...
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...
(java)Write the “Will I eat lunch” program (Use Nested If statements). Declare variables for each criteria. (haveMoney, haveTime, amHungry, restaurantOpen, haveTransportation ) Have the user input the values for each criteria. Use Nested if statements to determine if user will eat lunch today. Inform the user why they are or are not having lunch at McDonalds.
In a class named Program8, write codes as follows: Declare a global integer variable called length and initialize it with zero as a default value. (Difficulty: easy) Write a method called setLength which accepts an integer input num and counts how many digits this number has and sets the global variable length with the result. This method does not return anything, instead it assigns a new value into the global variable length. This method should also work with negative numbers....
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....