Introduction to Java Programming and Data Structures, Comprehensive Version, Student Value Edition (11th Edition)
11th Edition
ISBN: 9780134671604
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 13.6, Problem 13.6.3CP
Can the following code be compiled? Why?
Integer n1 = new Integer(3);
Object n2 = new Integer(4);
System.out.println(n1.compareTo(n2));
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Method: sumOdds(value: int): This method will sum all the odd values from 1 upto the value passed by parameter. This will display the sumas an integer value.Method: characterCount(phrase: str): This method will count the number of characters in the phrase that is passed by parameter. You cannot useany built in function ( ie len() ) and must use a looping activity. This should display the number of characters inthe phrase as an integerMethod: multiplicationPractice(): This method is to practice simple multiplication problems. The program should randomly generate twonumbers from 1-10 for the user to multiply. It should display the multiplication problem and allow the user toanswer the problem. It should display if the user got the answer correct or incorrect. The activity shouldcontinue until the user has gotten 3 different practice problems correct.Method: order(value1: int, value2: int, value3: int): This method is to order the 3 passed value from least to greatest. It should display…
In this assignment, you will need to add a new method to the Date class, which you
can find on D2L in the "Sample Code" section.
The new method should make a Date object's day, month, and year value change to
the next day. In other words, add one day to the object's current date. Do not use any
part of the built-in DateTime class, but you may want to use the DaysInMonth()
method from the Date class.
Examples:
• If the Date object stores the date 12/31/2021, then after calling your method
it should store the date 1/1/2022
• If the Date object stores the date 2/28/2022, then after calling your method it
should store the date 3/1/2022
As noted in the common instructions, you only need to turn in your new method, not
the entire Date class.
for java please
Please submit the pseudocode of your program for your project below.
Need a class which will contain:
Student Name
Student Id
Student Grades (an array of 3 grades)
A constructor that clears the student data (use -1 for unset grades)
Get functions for items a, b, and c, average, and letter grade
Set functions for items a, n, and c
Note that the get and set functions for Student grades need an argument for the grade index.
Need another class which will contain:
An Array of Students (1 above)
A count of number of students in use
You need to create a menu interface that allows you to:
Add new students
Enter test grades
Display all the students with their names, ids, test grades, average, and letter grade
Exit the program
Add comments and use proper indentation.
Nice Features:
I would like that system to accept a student with no grades, then later add one or more grades, and when all grades are entered, calculate the final average or grade.
I would like the system…
Chapter 13 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version, Student Value Edition (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...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Suppose the registers 0x4 and 0x5 in the Vole contain the bit patterns 0x3A and 0xC8, respectively. What bit pa...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Type in and run the 12 programs presented in this chapter. Compare the output produced by each program with the...
Programming in C
Restaurant Bill Write a program that computes the tax and tip on a restaurant bill. The program should ask the ...
Starting Out with Java: From Control Structures through Objects (6th Edition)
Write a statement that clears the contents of the List object created in Check point 7.22.
Starting out with Visual C# (4th Edition)
Widget Factory Design a class for a widget manufacturing plant. Assuming that 10 widgets may be produced each h...
Starting Out with C++: Early Objects (9th Edition)
What is the highest decimal number that can be represented by each of the following numbers of binary digits (b...
Digital Fundamentals (11th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- #include | int main() { int n=5; for (int i=1;iarrow_forwarda) FindMinIterative public int FindMin(int[] arr) { int x = arr[0]; for(int i = 1; i < arr.Length; i++) { if(arr[i]< x) x = arr[i]; } return x; } b) FindMinRecursive public int FindMin(int[] arr, int length) { if(length == 1) return arr[0]; return Math.Min(arr[length - 1], Find(arr, length - 1)); } What is the Big-O for this functions. Could you explain the recurisive more in details ?arrow_forwardDescription: The program prompts the user to enter three numbers and invokes the method: public static void displayIncreasingNumbers(int num1, double num2, long num3) to display them in increasing order. Below is my code: package threeincreasingnumbers; import java.util.Scanner; public class Threeincreasingnumbers { public static void main(String[] args) {// Create Scanner Scanner scan = new Scanner(System.in); // Prompt the user to enter three numbersSystem.out.print("Enter three numbers: ");int num1 = scan.nextInt();double num2 = scan.nextDouble();long num3 = scan.nextLong(); // Display numbers in increasing orderdisplayIncreasingNumbers(num1, num2, num3);}public static void displayIncreasingNumbers(int num1, double num2, long num3) {double temp; if (num2 < num1 && num2 < num3){temp = num1;num1 = (int) (double) num2;num2 = temp;}else if (num3 < num1 && num3 < num2) {temp = num1; num1 = (int) num3;num3 = (long) temp;}if (num3 < num2) {temp = num2;num2 =…arrow_forwardPlease rewrite the code: Here is the code: class PidManager {// Declare the range of possible pid valuesprivate static final int MIN_PID = 300;private static final int MAX_PID = 5000; // Declare a memory locationprivate static int[] pids; // Create a method named allocatMap().// This method is used to allocate the// memory to store the pids.public static int allocatMap() {pids = new int[MAX_PID - MIN_PID];if (pids == null) {System.out.println("Memory allocation failed.");return -1;} for (int i = 0; i < pids.length; i++) {pids[i] = 0;}System.out.println("Memory allocated successfully.");return 1;} // Create a method named allocatPID().// This method is used to allocates and returns a pid.public static int allocatPID() {if (pids == null) {System.out.println("PID Manager is not initialized ");return -1;} int pidNum = -1; for (int i = 0; i < pids.length; i++) {if (pids[i] == 0) {pids[i] = 1;pidNum = i + MIN_PID;break;}}if (pidNum == -1) {System.out.println("Unable to allocat…arrow_forwardMagic Squares One interesting application of two-dimensional arrays is magic squares. A magic square is a square matrix in which the sum of every row, every column, and both diagonals is the same. Magic squares have been studied for many years, and there are some particularly famous magic squares. In this exercise you will write code to determine whether a square is magic. File Square.java contains the shell for a class that represents a square matrix. It contains headers for a constructor that gives the size of the square and methods to read values into the square, print the square, find the sum of a given row, find the sum of a given column, find the sum of the main (or other) diagonal, and determine whether the square is magic. The read method is given for you; you will need to write the others. Note that the read method takes a Scanner object as a parameter. File SquareTest.java contains the shell for a program that reads input for squares from a file named magicData and tells…arrow_forwardthis practice assignment wants me to : Write an application that asks a user to enter an integer. Display a statement that indicates whether the integer is even or odd. it is saying that i am missing a return statement. here is my code: mport java.util.Scanner; class EvenOdd { public static void main(String[] args) { Scanner input = new Scanner(System.in); int number; System.out.println("Enter the integer >>>"); number = input.nextInt(); } public static boolean isEven(int number) { if (number % 2 == 0) System.out.println("The number is even."); else System.out.println("The number is odd."); } }arrow_forwardBasic Java Help Each year, the Social Security Administration provides a list of baby names for boy and girls by state. You will write a program to read a file containing a list of baby names and display the top names. To start, implement the following class: baby names util = printTopNames(File, int): void printTopNames Will be a static method. It will accept two parameters, one is a File containing the list of names. The other is an integer that indicates how many names to display (ie, top 10 names, or top 50 names, etc). The integer argument could be any valid integer. You do not have to worry about an integer value large than 5 for the boy/girl names. This method should open the file and parse the file and print the names as shown below: Your program will use the Scanner class to read the data from the file (see your text for examples). You will also need to use a delimiter with the scanner so that the scanner will break the line apart based on the commas. For this file, set…arrow_forwardTrue or False? Arrays cannot be passed as parameters, but must be used only in the main method.arrow_forwardWhat does the following code do? In [1]: def mystery (a, b) : if b == 1: return a else: return a + mystery (a, b - 1) In [2]: mystery (2, 10) Out [2]: ?????arrow_forwardFill in the blank with the correct answer/output. int[] nums = {78, 94, 850, 425, 375, 67}; int[] numsTen = {1,2,3,4,5,6,7,8,9,10}; double[] dblNums = {3.4, 2.75, 3.8, 4.0, 1.5} System.out.print( dblNums [0]); // LINE 1 1. wor www w System.out.print (nums [3]-25); // LINE 2 2. System.out.print{ nums [5]); // LINE 3 3. System.out.print( dblNums [3]); // LINE 4 4. System.out.print (numTens.length) ; // LINE 5 5. System.out.print (numsTen.length/2); // LINE 6 6. System.out.print (numsTen [6]); // LINE 7 7. System.out.print nums [0]); // LINE 8 8. System.out.print nums [9]); // LINE 9 9. System.out.print nums [6/2] ); // LINE 1o 10. System.out.print{ numsTen [2] ); // LINE 11 11. System.out.print{ dblNums [db1Nums.length-1]); // LINE 12 12. System.out.print nums [5/4]); // LINE 13 13. System.out.print{ nums [3]); // LINE 14 14.arrow_forwardRead the code segment below. What will be the output of the code segment? for (int i = 0; i <= 11; i++) { System.out.println(arr[i*2]);}314159265358979323846 34525599286with an error 31415926535 34525599286arrow_forward. Create a testEmployees class. Do the following: Declare an array called arrEmp of 10 Employee type objects in the main method. Write a static method called fillArray() that receives the arrEmp array. Use a while loop to enter the information (type of contract) of a number of new employees. Quit input by entering the character X instead of the type of contract. For each employee create an object and save the object in the array. Return the array to the main method. Call the static fillArray() method from the main method. Write a static method called displayArray() to receive the array and display a numbered list of the information of the employees using a for-loop and the toString() method. Call the static displayArray() method from the main method. Write a static method called updateEmpCommission() to receive the array and update the commission of some of the employees as follows: Use a loop to update a number of employees' commission. Use a sentinel value -1 to…arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
9.1: What is an Array? - Processing Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=NptnmWvkbTw;License: Standard Youtube License