Java How To Program (Early Objects)
10th Edition
ISBN: 9780133807943
Author: Deitel, Paul
Publisher: Pearson Education
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 5, Problem 5.3E
Explanation of Solution
Given statements:
//iterate "i" until it reaches 1
for (i = 19; i >= 1; i+= 2) {//Line 1
//display the "i"
System.out.println(i); //Line 2
}//Line 3
Error in the statement:
Error #1:
Here, the “for” statem...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
int power(int base,int exp);
*This function accepts the
arguments for base and exponent
and returns power. The algorithm is
to repeatedly multiply the value of
the base to how many time the value
of exponent.*
For example:
Test Input Result
printf("%d",power(2,5)); 2 32
5
printf("%d",power(3,4)); 3 81
4
-Use C language, please. Thank you.
PROBLEM: Repetition Control Structure (while, do-while)
SHOW THE CODES IN ANY JAVA APPLICATION LIKE JCRATOR AND ECLIPSE. OUTPUT SHOULD BE LIKE IN THE TABLE.
What does this function using to?
int max(int a , int b)
if(a > b) return a;
else
return b;
}
returns the maximum of two integer
numbers
returns the minimum of two integer
numbers
returns the maximum of an floating
point numbers
returns the minimum of two floating
point numbers
Chapter 5 Solutions
Java How To Program (Early Objects)
Ch. 5 - Fill in the blanks in each of the following...Ch. 5 - Fill in the blanks in each of the following...Ch. 5 - Fill in the blanks in each of the following...Ch. 5 - Fill in the blanks in each of the following...Ch. 5 - Fill in the blanks in each of the following...Ch. 5 - Prob. 1.6SRECh. 5 - Prob. 1.7SRECh. 5 - State whether each of the following is true or...Ch. 5 - State whether each of the following is true or...Ch. 5 - State whether each of the following is true or...
Ch. 5 - State whether each of the following is true or...Ch. 5 - Prob. 2.5SRECh. 5 - State whether each of the following is true or...Ch. 5 - Prob. 2.7SRECh. 5 - Prob. 3.1SRECh. 5 - Prob. 3.2SRECh. 5 - Write a Java statement or a set of Java statements...Ch. 5 - Prob. 3.4SRECh. 5 - Find the error in each of the following code...Ch. 5 - Find the error in each of the following code...Ch. 5 - Find the error in each of the following code...Ch. 5 - Find the error in each of the following code...Ch. 5 - Describe the four basic elements of...Ch. 5 - Compare and contrast the while and for iteration...Ch. 5 - Prob. 3.1ECh. 5 - Compare and contrast the break and continue...Ch. 5 - Find and correct the error(s) in each of the...Ch. 5 - The following code should print whether integer...Ch. 5 - Prob. 5.3ECh. 5 - Find and correct the error(s) in each of the...Ch. 5 - What does the following program do? 1 // Exercise...Ch. 5 - (Find the Smallest Value) Write an application...Ch. 5 - (Calculating the Product of Odd Integers) Write an...Ch. 5 - (Factorials) Factorials are used frequently in...Ch. 5 - (Modified Compound-Interest Program) Modify the...Ch. 5 - (Triangle Printing Program) Write an application...Ch. 5 - (Bar-Chart Printing Program) One interesting...Ch. 5 - (Calculating Sales) An online retailer sells five...Ch. 5 - (Modified Compound-Interest Program) Modify the...Ch. 5 - Assume that i = 1, j = 2, k = 3 and m = 2. What...Ch. 5 - (Calculating the Value of ) Calculate the value of...Ch. 5 - (Pythagorean Triples) A right triangle can have...Ch. 5 - (Modified Triangle-Printing Program) Modify...Ch. 5 - (De Morgans Laws) In this chapter, we discussed...Ch. 5 - (Diamond-Printing Program) Write an application...Ch. 5 - Prob. 21.1ECh. 5 - A criticism of the break statement and the...Ch. 5 - What does the following program segment do? 1 for...Ch. 5 - Describe in general how youd remove any continue...Ch. 5 - Prob. 25.1ECh. 5 - (Facebook User Base Growth) According to...
Knowledge Booster
Similar questions
- When you perform arithmetic operations with operands of different types, such as adding an int and a float, ____________. C# chooses a unifying type for the result you must choose a unifying type for the result you must provide a cast you receive an error messagearrow_forward(Numerical) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters to 0, and then generate a large number of pseudorandom integers between 0 and 9. Each time a 0 occurs, increment the variable you have designated as the zero counter; when a 1 occurs, increment the counter variable that’s keeping count of the 1s that occur; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of the time they occurred.arrow_forwardfunction avg and pass x and y Tin printf ("the avg of x and y is %d\n', avgl) give_sqrt (avgl); return 0, float avg (float m, float n) I/ Return the average of n and m void give sqrt (float x) printf ('the sqrt of is Mn'x :/ Print the sqrt value of x. return;arrow_forward
- (Python matplotlib or seaborn) CPU Usage We have the hourly average CPU usage for a worker's computer over the course of a week. Each row of data represents a day of the week starting with Monday. Each column of data is an hour in the day starting with 0 being midnight. Create a chart that shows the CPU usage over the week. You should be able to answer the following questions using the chart: When does the worker typically take lunch? Did the worker do work on the weekend? On which weekday did the worker start working on their computer at the latest hour? cpu_usage = [ [2, 2, 4, 2, 4, 1, 1, 4, 4, 12, 22, 23, 45, 9, 33, 56, 23, 40, 21, 6, 6, 2, 2, 3], # Monday [1, 2, 3, 2, 3, 2, 3, 2, 7, 22, 45, 44, 33, 9, 23, 19, 33, 56, 12, 2, 3, 1, 2, 2], # Tuesday [2, 3, 1, 2, 4, 4, 2, 2, 1, 2, 5, 31, 54, 7, 6, 34, 68, 34, 49, 6, 6, 2, 2, 3], # Wednesday [1, 2, 3, 2, 4, 1, 2, 4, 1, 17, 24, 18, 41, 3, 44, 42, 12, 36, 41, 2, 2, 4, 2, 4], # Thursday [4, 1, 2, 2, 3, 2, 5, 1, 2, 12, 33, 27, 43, 8,…arrow_forward4. Odd-Even-inator by CodeChum Admin My friends are geeking out with this new device I invented. It checks if a number is even or odd! ? Do you want to try it out? Instructions: In the code editor, you are provided with a function that checks whether a number is even or odd. Your task is to ask the user for the number of integer, n, they want to input and then the actual n number values. For each of the number, check whether it is even or odd using the function provided for you. Make sure to print the correct, required message. Input 1. Integer n 2. N integer valuesarrow_forwardthis code is not workingarrow_forward
- 6.Coding-----""Euler's totient function, also known as phi-function ϕ(n),counts the number of integers between 1 and n inclusive,which are coprime to n.(Two numbers are coprime if their greatest common divisor (GCD) equals 1)."""def euler_totient(n): """Euler's totient function or Phi function. Time Complexity: O(sqrt(n)).""" result = n for i in range(2, int(n ** 0.5) + 1): if n % i == 0: while n % i == 0: n //= i.arrow_forwardIdentify and fix the errors in the following code segment.arrow_forwardWrite C code that calculates and prints the volumes of different shapes (Sphere and Frustumarrow_forward
- Change this code into a program that receives a number and prints its divisors.( C language) #include <stdio.h> int main() { unsigned guess; /* current guess for prime */ unsigned factor; /* possible factor of guess */ unsigned limit; /* find primes up to this value */ printf("Find primes up to: "); scanf("%u", &limit); printf("2\n"); /* treat first two primes as special case */ printf("3\n"); guess = 5; /* initial guess */ while ( guess <= limit ) { /* look for a factor of guess */ factor = 3; while ( factor*factor < guess && guess % factor != 0 ) factor += 2;if ( guess % factor != 0 ) printf("%d\n", guess); guess += 2; /* only look at odd numbers */ } return 0; }arrow_forwardDo not use array or advance logic simple c++ Write and test the “digit” function:Function Prototype: int digit(int n,int k)This function returns the kth digit of the positive integer n. For example, if n is the integer29,415, then the call digit(n,0) would return the digit 2, and the call digit(n,2) would returnthe digit 4.Examples:Input: n = 29415 , k = 1 output: 9Marks: 02Input: n = 2 , k = 0 output: 2 n = 2 , k = 1 output: index out of bound (return -1)Note:• The digits are numbered from left to right beginning with the “zeroth” digit.• Take input and display output in main function.arrow_forwardWhich of the following arithmetic operations may be performed on struct variables but not on array variables?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr