Pearson eText for Starting Out with Java: Early Objects -- Instant Access (Pearson+)
Pearson eText for Starting Out with Java: Early Objects -- Instant Access (Pearson+)
6th Edition
ISBN: 9780137516803
Author: Tony Gaddis
Publisher: PEARSON+
bartleby

Concept explainers

Question
Book Icon
Chapter 10, Problem 4PC
Program Plan Intro

Month class exception

Program Plan:

Month.java:

  • Definition of class “Month”.
    • Declare the variable “monNum” as “int”.
    • Create a constructor for “Month()”.
      • Assign “monNum” to “1”.
    • Create a parameterized constructor which throws the “InvalidMonthNumExc”.
      • Check the condition.
        • Throw the exception.
      • Otherwise, assign “m” to “monNum”.
    • Create a parameterized constructor which throws the “InvalidMonthNumExc”.
      • Check the condition.
        • Assign “1” to “monNum”.
      • Condition to check the month is “february”.
        • Assign “2” to “monNum”.
      • Condition to check the month is “march”
        • Assign “3” to “monNum”.
      • Condition to check the month is “april”.
        • Assign “4” to “monNum”.
      • Condition to check the month is “may”
        • Assign “5” to “monNum”.
      • Condition to check the month is “june”.
        • Assign “6” to “monNum”.
      • Condition to check the month is “july”
        • Assign “7” to “monNum”.
      • Condition to check the month is “august”
        • Assign “8” to “monNum”.
      • Condition to check the month is “September”.
        • Assign “9” to “monNum”.
      • Condition to check the month is :”October”.
        • Assign “10” to “monNum”.
      • Condition to check the month is “November”.
        • Assign “11” to “monNum”.
      • Condition to check the month is “December”.
        • Assign “12” to “monNum”.
    • Mutator method “setMonNum()”
      • Check the condition and throw the exception
    • Accessor method “getMonNum()”.
      • Return the “monNum”.
    • Accessor method “getMonName()”.
      • Declare the variable “name”.
        • Switch case to check the month equals to “January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”.
        • Return the name.
    • Method definition for “toString()”.
      • Return the “getMonName()”.
    • Method definition of “equals()”
      • Declare the boolean variable “flag”.
      • Check the condition and assign the flag variable “true” or “false” according to the condition.

InvalidMonthNumExc.java:

  • Definition for “InvalidMonthNumExc”
    • Definition for non-parameterized constructor.
      • Print the statement.
    • Definition for parameterized constructor
      • Print the statement.

InvalidMonthNameExc.java:

  • Definition for “InvalidMonthNameExc”
    • Definition for non-parameterized constructor.
      • Print the statement.
    • Definition for parameterized constructor
      • Print the statement.

DemoOne.java:

  • Definition of class “DemoOne”.
  • Definition of main class.
    • Create an object “m” for “month()”.
      • Inside the try block,
        • Print the month
      • Inside the catch block,
        • Print the exception.

DemoTwo.java:

  • Definition of class “DemoTwo”.
  • Definition of main class.
    • Inside the try block,
      • Create an object “m” for “month()”.
      • Print the month
    • Inside the catch block,
      • Print the exception.

DemoThree.java:

  • Definition of class “DemoThree”.
  • Definition of main class.
    • Inside the try block,
      • Create an object “m” for “month()”.
      • Print the month
    • Inside the catch block,
      • Print the exception.
    • Inside the try block,
      • Create an object “m1” for “month()”.
      • Print the month
    • Inside the catch block,
      • Print the exception.

Blurred answer
Students have asked these similar questions
Assume that a string of name & surname is saved in S. The alphabetical characters in S can be in lowercase and/or uppercase letters. Name and surname are assumed to be separated by a space character and the string ends with a full stop "." character. Write an assembly language program that will copy the name to NAME in lowercase and the surname to SNAME in uppercase letters. Assume that name and/or surname cannot exceed 20 characters. The program should be general and work with every possible string with name & surname. However, you can consider the data segment definition given below in your program. .DATA S DB 'Mahmoud Obaid." NAME DB 20 DUP(?) SNAME DB 20 DUP(?) Hint: Uppercase characters are ordered between 'A' (41H) and 'Z' (5AH) and lowercase characters are ordered between 'a' (61H) and 'z' (7AH) in the in the ASCII Code table. For lowercase letters, bit 5 (d5) of the ASCII code is 1 where for uppercase letters it is 0. For example, Letter 'h' Binary ASCII 01101000 68H 'H'…
What did you find most interesting or surprising about the scientist Lavoiser?
1. Complete the routing table for R2 as per the table shown below when implementing RIP routing Protocol? (14 marks) 195.2.4.0 130.10.0.0 195.2.4.1 m1 130.10.0.2 mo R2 R3 130.10.0.1 195.2.5.1 195.2.5.0 195.2.5.2 195.2.6.1 195.2.6.0 m2 130.11.0.0 130.11.0.2 205.5.5.0 205.5.5.1 R4 130.11.0.1 205.5.6.1 205.5.6.0

Chapter 10 Solutions

Pearson eText for Starting Out with Java: Early Objects -- Instant Access (Pearson+)

Ch. 10.1 - What is the call stack? What is a stack trace?Ch. 10.1 - Prob. 10.12CPCh. 10.1 - Prob. 10.13CPCh. 10.1 - Prob. 10.14CPCh. 10.2 - What does the throw statement do?Ch. 10.2 - Prob. 10.16CPCh. 10.2 - Prob. 10.17CPCh. 10.2 - Prob. 10.18CPCh. 10.2 - Prob. 10.19CPCh. 10.3 - What is the difference between a text file and a...Ch. 10.3 - What classes do you use to write output to a...Ch. 10.3 - Prob. 10.22CPCh. 10.3 - What class do you use to work with random access...Ch. 10.3 - What are the two modes that a random access file...Ch. 10.3 - Prob. 10.25CPCh. 10 - Prob. 1MCCh. 10 - Prob. 2MCCh. 10 - Prob. 3MCCh. 10 - Prob. 4MCCh. 10 - FileNotFoundException inherits from __________. a....Ch. 10 - Prob. 6MCCh. 10 - Prob. 7MCCh. 10 - Prob. 8MCCh. 10 - Prob. 9MCCh. 10 - Prob. 10MCCh. 10 - Prob. 11MCCh. 10 - Prob. 12MCCh. 10 - Prob. 13MCCh. 10 - Prob. 14MCCh. 10 - Prob. 15MCCh. 10 - This is the process of converting an object to a...Ch. 10 - Prob. 17TFCh. 10 - Prob. 18TFCh. 10 - Prob. 19TFCh. 10 - True or False: You cannot have more than one catch...Ch. 10 - Prob. 21TFCh. 10 - Prob. 22TFCh. 10 - Prob. 23TFCh. 10 - Prob. 24TFCh. 10 - Find the error in each of the following code...Ch. 10 - // Assume inputFile references a Scanner object,...Ch. 10 - Prob. 3FTECh. 10 - Prob. 1AWCh. 10 - Prob. 2AWCh. 10 - Prob. 3AWCh. 10 - Prob. 4AWCh. 10 - Prob. 5AWCh. 10 - Prob. 6AWCh. 10 - The method getValueFromFile is public and returns...Ch. 10 - Prob. 8AWCh. 10 - Write a statement that creates an object that can...Ch. 10 - Assume that the reference variable r refers to a...Ch. 10 - Prob. 1SACh. 10 - Prob. 2SACh. 10 - Prob. 3SACh. 10 - Prob. 4SACh. 10 - Prob. 5SACh. 10 - Prob. 6SACh. 10 - What types of objects can be thrown?Ch. 10 - Prob. 8SACh. 10 - Prob. 9SACh. 10 - Prob. 10SACh. 10 - What is the difference between a text file and a...Ch. 10 - What is the difference between a sequential access...Ch. 10 - What happens when you serialize an object? What...Ch. 10 - TestScores Class Write a class named TestScores....Ch. 10 - Prob. 2PCCh. 10 - Prob. 3PCCh. 10 - Prob. 4PCCh. 10 - Prob. 5PCCh. 10 - FileArray Class Design a class that has a static...Ch. 10 - File Encryption Filter File encryption is the...Ch. 10 - File Decryption Filter Write a program that...Ch. 10 - TestScores Modification for Serialization Modify...Ch. 10 - Prob. 11PC
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr