تم الحل ✓
categoryبرمجة وتطوير البرمجيات
schoolبكالوريوس
event_available2026-07-14
السؤال
Transcribed Image Text:
1
2 // Java core packages
3 import java.text.DecimalFormat;
4 import java.time.LocalDate;
5
6 // Java extension packages
7 import javax.swing.JOptionPane; Demonstrating Polymorphism
8
9 public class Test {
В
1
28
3
4
6
7
8
9
1
2
3
4
// test book hierarchy
public static void main(Stri
Book book; // superclass
String output = "";
Novel novel new Novel(
EducationBook educationb
LocalDate. of (191
Classic classic = new Cl
DecimalFormat precision2
// book reference to a n
book ■ novel;
i
Novel: 1 Harry Potter J.K Rowling 1992-03-26 costs $20.00
Novel: 1 Harry Potter J.K Rowling 1992-03-26 costs $20.00
Education Book: 2 My Maths 3 James Jones 1913-03-26 costs $62.40
Education Book: 2 My Maths 3 James Jones 1913-03-26 costs $62.40
Classic: 3 The Great Gatsby F. Scott Fitzgerald 1800-03-26 costs $35.00
Classic: 3 The Great Gatsby F. Scott Fitzgerald 1800-03-26 costs $35.00
Book: Novel: 1 Harry Potter J.K Rowling 1992-03-26, cost: 20.0
X
Book: Education Book: 2 My Maths 3 James Jones 1913-03-26, cost: 62.4
Book: Classic: 3 The Great Gatsby F. Scott Fitzgerald 1800-03-26, cost: 35.0
Education Book: 4 My Maths 4 James Jones 1913-03-26 Cost Error: Total Book Cost cannot be negative.
Book: Classic: 5 The Greatest Harry F. SNEwewcott Fitzgerald 2018-03-26, cost: 35.0
Total Cost: 186.788
OK
7
try {
5698231
output += book.toString() + "costs $" + precision2.format(book.cost()) + "\n" + novel.toString()
+ costs $" + precision2. format (novel.cost()) + "\n";
"
// book reference to a educationbook
LILE
check_circle الجواب — حل مفصل خطوة بخطوة
hourglass_top
🔒
الحل الكامل متاح للمشتركين
اشترك في أرشيف الأسئلة لعرض هذا الحل وآلاف الحلول المفصلة خطوة بخطوة من معلمين معتمدين.