Question
1) Write Java statements that accomplish each of the following tasks: a) Display the message Enter an integer:, leaving the cursor on the same line.
1) Write Java statements that accomplish each of the following tasks:
a) Display the message "Enter an integer:", leaving the cursor on the same line.
b) Assign the product of variables b and c to the int variable a.
c) Use a comment to state that a program performs a sample payroll calculation.
2) What is a default constructor? How are an objects instance variables initialized if a class has only a default constructor?
3) Explain what happens when a Java program attempts to divide one integer by another. What happens to the fractional part of the calculation? How can you avoid that outcome?
4) What is the value of x after each of the following statements is executed? a. double x = Math.abs(7.5); b. double x = Math.floor(7.5); c. double x = Math.abs(0.0); d. double x = Math.ceil(0.0); e. double x = Math.abs(-6.4); f. double x = Math.ceil(-6.4); g. double x = Math.ceil(-Math.abs(-8 + Math.floor(-5.5)));
5) Write statements that perform the following one-dimensional-array operations: a. Set the 10 elements of integer array counts to zero. b. Add one to each of the 15 elements of integer array bonus. c. Display the five values of integer array bestScores in column format.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started