How should the average calculation below be modified to compute the correct average of the two numbers?int num1 = 10;int num2 = 20;double average = 0.0;average = num1 + num2 / 2;
What will be an ideal response?
Answers can vary; however the major steps would be to (1) type cast the num1 and num2 variables to be of the double data type, (2) place parentheses around the (num1 + num2) part of the calculation, and (3) make the value 2 a double value (2.0). One valid answer could be as follows:
average = ( static_cast(num1) + static_cast(num2) ) / 2.0;
You might also like to view...
The controlling expression for a switch statement includes all of the following types except:
(a) char (b) int (c) byte (d) double
A ________ can be set by an employer to prevent you from accessing eBay
A) switch B) firewall C) router D) wireless access point
You are the owner of a hardware store and need to keep an inventory that can tell you what different tools you have, how many of each you have on hand and the cost of each one. Write a program that initializes the shelve file "hardware.dat", lets you input the data concerning each tool and enables you to list all your tools. The tool identification number should be the record number. Use the
following information to start your file:  What will be an ideal response?
String sentence;String str1, str2, str3, str4;int length1;sentence = "First exam is on Monday.";str1 = sentence.substring(6, 12);str2 = str1.substring(0, 4);str3 = sentence.replace('i', '#');str4 = sentence.indexOf("on");length1 = sentence.length();Based on the code above, what is the value of length1?
A. 20 B. 21 C. 24 D. 26