Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 13.3, Problem 13.3.2CP
Program Plan Intro
Given Code:
//declaration of class
public abstract class ex1
{
//declaration of main method
public static void main(String[] args)
{
/*creation of an array of integer type named "numberArray" having size 2 */
Number[] numberArray = new Integer[2];
/*creation of a double object */
numberArray[0] = new Double(1.5);
}
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What happens when the ref or out keyword is used with an array parameter?
In C++
Create an array of random 10 random numbers. Use the "range-based for loop" (sometimes called "enhanced for loop") to put the values into the array (users choice of number) and use the "range-based for loop" to output the numbers to the console.
Please help how to fix my code?
My code!
#include <stdio.h>
struct Student{int id;char name[30];float percent;};
int main() {struct Student s[3];for(int i=0;i<3;i++){scanf("%d",&s[i].id);scanf("%s",s[i].name);scanf("%f",&s[i].percent);}for(int i=0;i<3;i++){printf("Records of Student %d",i+1);printf("\nID :%d",s[i].id);printf("\nName: %s",s[i].name);printf("\nPercentage :%.2f",s[i].percent);printf("\n");}return 0;}
Chapter 13 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 13.2 - Prob. 13.2.1CPCh. 13.2 - The getArea() and getPerimeter() methods may be...Ch. 13.2 - True or false? a.An abstract class can be used...Ch. 13.3 - Prob. 13.3.1CPCh. 13.3 - Prob. 13.3.2CPCh. 13.3 - Prob. 13.3.3CPCh. 13.3 - What is wrong in the following code? (Note the...Ch. 13.3 - What is wrong in the following code? public class...Ch. 13.4 - Can you create a Calendar object using the...Ch. 13.4 - Prob. 13.4.2CP
Ch. 13.4 - How do you create a Calendar object for the...Ch. 13.4 - For a Calendar object c, how do you get its year,...Ch. 13.5 - Prob. 13.5.1CPCh. 13.5 - Prob. 13.5.2CPCh. 13.5 - Prob. 13.5.3CPCh. 13.5 - Prob. 13.5.4CPCh. 13.6 - Prob. 13.6.1CPCh. 13.6 - Prob. 13.6.2CPCh. 13.6 - Can the following code be compiled? Why? Integer...Ch. 13.6 - Prob. 13.6.4CPCh. 13.6 - What is wrong in the following code? public class...Ch. 13.6 - Prob. 13.6.6CPCh. 13.6 - Listing 13.5 has an error. If you add list.add...Ch. 13.7 - Can a class invoke the super.clone() when...Ch. 13.7 - Prob. 13.7.2CPCh. 13.7 - Show the output of the following code:...Ch. 13.7 - Prob. 13.7.4CPCh. 13.7 - What is wrong in the following code? public class...Ch. 13.7 - Show the output of the following code: public...Ch. 13.8 - Prob. 13.8.1CPCh. 13.8 - Prob. 13.8.2CPCh. 13.8 - Prob. 13.8.3CPCh. 13.9 - Show the output of the following code: Rational r1...Ch. 13.9 - Prob. 13.9.2CPCh. 13.9 - Prob. 13.9.3CPCh. 13.9 - Simplify the code in lines 8285 in Listing 13.13...Ch. 13.9 - Prob. 13.9.5CPCh. 13.9 - The preceding question shows a bug in the toString...Ch. 13.10 - Describe class-design guidelines.Ch. 13 - (Triangle class) Design a new Triangle class that...Ch. 13 - (Shuffle ArrayList) Write the following method...Ch. 13 - (Sort ArrayList) Write the following method that...Ch. 13 - (Display calendars) Rewrite the PrintCalendar...Ch. 13 - (Enable GeometricObject comparable) Modify the...Ch. 13 - Prob. 13.6PECh. 13 - (The Colorable interface) Design an interface...Ch. 13 - (Revise the MyStack class) Rewrite the MyStack...Ch. 13 - Prob. 13.9PECh. 13 - Prob. 13.10PECh. 13 - (The Octagon class) Write a class named Octagon...Ch. 13 - Prob. 13.12PECh. 13 - Prob. 13.13PECh. 13 - (Demonstrate the benefits of encapsulation)...Ch. 13 - Prob. 13.15PECh. 13 - (Math: The Complex class) A complex number is a...Ch. 13 - (Use the Rational class) Write a program that...Ch. 13 - (Convert decimals to fractious) Write a program...Ch. 13 - (Algebra: solve quadratic equations) Rewrite...Ch. 13 - (Algebra: vertex form equations) The equation of a...
Knowledge Booster
Similar questions
- What are the values of mynum[0], mynum [1], and mynum[2] after the following code executes? double[] mynum = new double[3]; double start = 1.5; for (double i : mynum) { i = start; start += 10.5; } а. 0.0 0.0 0.0 b. 1.5 12.0 22.5 с. 1.5 d. 22.5 1.5 1.5 22.5 22.5 e. Nothing will print due to an out of bounds errorarrow_forwarddef tpr(tp, fn): # TODO return def TEST_tpr(): tpr_score = tpr(tp=100, fn=1) todo_check([ (np.isclose(tpr_score,0.99009, rtol=.01),"tpr_score is incorrect") ]) TEST_tpr() garbage_collect(['TEST_tpr'])arrow_forwardin java Integer numVals is read from input and integer array userCounts is declared with size numVals. Then, numVals integers are read from input and stored into userCounts. Output all elements of userCounts in reverse order, following each element with a space, including the last. After the final output, end with a newline. Ex: If the input is 4 54 56 75 7 then the output is: Array contents in reverse: 7 75 56 54 Note: The loop should start with i = userCounts.length - 1 and end with i = 0. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 import java.util.Scanner; public class UserLog { publicstaticvoidmain(String[] args) { Scannerscnr=newScanner(System.in); intnumVals; inti; numVals=scnr.nextInt(); int[] userCounts=newint[numVals]; for (i=0; i<userCounts.length; ++i) { userCounts[i] =scnr.nextInt(); } System.out.print("Array contents in reverse: "); /* Your code goes here */ } }arrow_forward
- What is the value of d['a'] after the following lines of code are executed? d = {} d['a'] = 1 2 = [,q.]p d['c'] = 3 d['a'] = 4arrow_forwardin c++ write a code that takes an array of 10 integer values, finds and prints the following: Each value that appear in the array and its frequency (how many times the value appears in the array). The value with the maximum frequency. If two or more values have frequencies equal to the maximum frequency, the program prints the minimum value among these values.arrow_forwardAnalyze the following code:int matrix[5][5];for (int column = 0; column < 5; column++);matrix[4][column] = 10; Select the correct option: After the loop, the last row of matrix 10, 10, 10, 10, 10. After the loop, the last row of matrix 0, 0, 0, 0, 0. A syntax error, because column is not defined. After the loop, the last column of matrix 10, 10, 10, 10, 10. After the loop, the last row of matrix 0, 0, 0, 0, 10.arrow_forward
- Use the following code without changing anything to to produce the output that is attached. public class GradeBookTest { public static void main( String[] args ) { // two-dimensional array of student grades int[][] gradesArray = { { 87, 96, 70 }, { 68, 87, 90 }, { 94, 100, 90 }, { 100, 81, 82 }, { 83, 65, 85 }, { 78, 87, 65 }, { 85, 75, 83 }, { 91, 94, 100 }, { 76, 72, 84 }, { 87, 93, 73 } }; processGrades(gradesArray);rowAverage(row)lowestGrade(gradesArray);maxGrade(gradesArray); } // end main } // end class GradeBookTestarrow_forwardC language not C++ #includearrow_forwardAssuming buf is a valid pointer, what is the problem in the code below? What would be an alternate way of implementing this that would avoid the problem? size_t sz = buf->size(); while ( --sz >= 0 ) { /* do something */ }arrow_forward
- In main(), call WriteHeader(); Declare an array of 6 integers named numbers. Declare variables for sum and average. Open a do-while or while loop Ask the user to input 6 ints using the function void AskForInts(int nums[]); Call the function void CalcSumAndAve(int nums[],int &sum, double &ave); to calculate the sum and average. Of the 6 numbers in the array. Then display numbers, sum and average by calling the function void DisplayAll(int nums [], int sum, double ave); Ask the user if they want to do another using your function, DoAnother(), using the response to control the do-while or while loop.arrow_forwardgvwsrearrow_forwardplease solvearrow_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,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT