Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 4, Problem 23STE
Explanation of Solution
Given:Â Refer to Chapter 4, Display 4.11 for the definition of the class, DateSixthTry.
To find:Â Whether it is legal to add two functions, public int getMonth() and
private String getMonth(), to the definition of class or not.
Solution:Â
It is not valid to add the two functions to the definition of class...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
2. Signed Integers
Unsigned binary numbers work for natural numbers, but many calculations use negative
numbers as well. To deal with this, a number of different methods have been used to represent
signed numbers, but we will focus on two's complement, as it is the standard solution for
representing signed integers.
2.1 Two's complement
• Most significant bit has a negative value, all others are positive. So, the value of an n-digit
-2
two's complement number can be written as: Σ2 2¹ di 2n-1 dn
• Otherwise exactly the same as unsigned integers.
i=0
-
• A neat trick for flipping the sign of a two's complement number: flip all the bits (0 becomes 1,
or 1 becomes 0) and then add 1 to the least significant bit.
• Addition is exactly the same as with an unsigned number.
2.2 Exercises
For questions 1-3, answer each one for the case of a two's complement number and an
unsigned number, indicating if it cannot be answered with a specific representation.
1. (15 pts) What is the largest integer…
can u solve this question
1. Unsigned Integers
If we have an n-digit unsigned numeral dn-1d n-2...do in radix (or base) r, then the value of that
numeral is
n−1
r² di
Σi=0
which is basically saying that instead of a 10's or 100's place we have an r's or
r²'s place. For binary, decimal, and hex r equals 2, 10, and 16, respectively.
Just a reminder that in order to write down a large number, we typically use the IEC or SI
prefixing system:
IEC: Ki = 210, Mi = 220, Gi = 230, Ti = 240, Pi = 250, Ei = 260, Zi = 270, Yi = 280;
SI: K=103, M = 106, G = 109, T = 10¹², P = 1015, E = 10¹8, Z = 1021, Y = 1024.
1.1 Conversions
a. (15 pts) Write the following using IEC prefixes: 213, 223, 251, 272, 226, 244
21323 Ki8 Ki
223 23 Mi 8 Mi
b. (15 pts) Write the following using SI prefixes: 107, 10¹7, 10¹¹, 1022, 1026, 1015
107 10¹ M = 10 M
=
1017102 P = 100 P
c. (10 pts) Write the following with powers of 10: 7 K, 100 E, 21 G
7 K = 7*10³
Chapter 4 Solutions
Absolute Java (6th Edition)
Ch. 4 - Write a method called makeItNewYears that could be...Ch. 4 - Write a method called yellIfNewYear that could be...Ch. 4 - Prob. 3STECh. 4 - Write a method called happyGreeting that could be...Ch. 4 - Prob. 5STECh. 4 - Write a method called advanceYear that could be...Ch. 4 - Prob. 7STECh. 4 - Prob. 8STECh. 4 - Consider the definition of the method monthString...Ch. 4 - The method writeOutput in Display 4.2 uses the...
Ch. 4 - Rewrite the definitions of the methods getDay and...Ch. 4 - Rewrite the method getMonth in Display 4.2 using...Ch. 4 - In the definition of precedes in Display 4.7, we...Ch. 4 - Prob. 14STECh. 4 - Following the style guidelines given in this book,...Ch. 4 - Prob. 16STECh. 4 - List all the accessor methods in the class...Ch. 4 - List all the mutator methods in the class...Ch. 4 - Write a better version of the method dateOK with...Ch. 4 - What is the signature of each of the following...Ch. 4 - Prob. 21STECh. 4 - Prob. 22STECh. 4 - Prob. 23STECh. 4 - If a class is named CoolClass, what names are...Ch. 4 - Suppose you have defined a class such as the...Ch. 4 - What is a no-argument constructor? Does every...Ch. 4 - What would be the last line in the dialogue in...Ch. 4 - What would be the last line in the dialogue in...Ch. 4 - Write a program that outputs a certain coded...Ch. 4 - Prob. 2PPCh. 4 - Define a class called Journal that could be used...Ch. 4 - Define a class called WordCount whose objects...Ch. 4 - Write a grading program for a class with the...Ch. 4 - Prob. 7PPCh. 4 - Redefine the class Date in Display 4.13 so that...Ch. 4 - Define a class whose objects are records on animal...Ch. 4 - Prob. 10PPCh. 4 - Prob. 11PPCh. 4 - This programming project extends Programming...Ch. 4 - Your Community Supported Agriculture (CSA) farm...Ch. 4 - A comma-separated values (CSV) file is a simple...Ch. 4 - Prob. 15PP
Knowledge Booster
Similar questions
- answer shoul avoid using AI and should be basic and please explainarrow_forwardNode A is connected to node B by a 2000km fiber link having a bandwidth of 100Mbps. What is the total latency time (transmit + propagation) required to transmit a 4000 byte file using packets that include 1000 Bytes of data plus 40 Bytes of header.arrow_forwardanswer should avoid using AI and should be basic and explain pleasearrow_forward
- answer should avoid using AI (such as ChatGPT), do not any answer directly copied from AI would and explain codearrow_forwardanswer should avoid using AI (such as ChatGPT), do not any answer directly copied from AI would and explain codearrow_forwardWrite a c++ program that will count from 1 to 10 by 1. The default output should be: 1, 2, 3, 4, 5, 6 , 7, 8, 9, 10 There should be only a newline after the last number. Each number except the last should be followed by a comma and a space. To make your program more functional, you should parse command line arguments and change behavior based on their values. Argument Parameter Action -f, --first yes, an integer Change place you start counting -l, --last yes, an integer Change place you end counting -s, --skip optional, an integer, 1 if not specified Change the amount you add to the counter each iteration -h, —help none Print a help message including these instructions. -j, --joke none Tell a number based joke. So, if your program is called counter, counter -f 10 --last 4 --skip 2 should produce 10, 8, 6, 4 Please use the last supplied argument. If your code is called counter, counter -f 4 -f 5 -f 6 should count from 6. You should…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher: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
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning