Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
bartleby

Concept explainers

Question
Book Icon
Chapter 11, 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
Write the set of SQL commands necessary to insert the data into the INVOICE table you created in Problem 17, as illustrated in Figure P8.16.
Refer to the shampoo_sales.xlsx time-series dataset. This data shows sales of shampoo over three years monthly. Carry out simple exponential smoothing and Holt's Trend-Corrected on this data and determine whether the data shows any trend. Assume the initial value for the level smoothing parameter (alpha) and Trend smoothing parameter (gamma) is 0.5 Month Sales of shampoo over a three year period 1-Jan 266 1-Feb 145.9 1-Mar 183.1 1-Apr 119.3 1-May 180.3 1-Jun 168.5 1-Jul 231.8 1-Aug 224.5 1-Sep 192.8 1-Oct 122.9 1-Nov 336.5 1-Dec 185.9 2-Jan 194.3 2-Feb 149.5 2-Mar 210.1 2-Apr 273.3 2-May 191.4 2-Jun 287 2-Jul 226 2-Aug 303.6 2-Sep 289.9 2-Oct 421.6 2-Nov 264.5 2-Dec 342.3 3-Jan 339.7 3-Feb 440.4 3-Mar 315.9 3-Apr 439.3 3-May 401.3 3-Jun 437.4 3-Jul 575.5 3-Aug 407.6 3-Sep 682 3-Oct 475.3 3-Nov 581.3 3-Dec 646.9
dy Car x Mail Kare x Golden Ge × University x Course Cn x Essential ( x A Content/ x Smartworx Essential C ncia.wwnorton.com/274325 r 3: Problem Set Due Date: 10/15/25 This is a Multiple Choice question/It is worth 1 point/You have 1 of 2 attempts remaining/There is a 1% attempt penalty 17 Question (1 point) ✓ 2nd attempt ☆ Σ entok9826@uapb For the reaction ATP + H2O ADP + P, the AG -30.5 kJ/mol. What would be the associated equilibrium constant for this reaction? Choose one: O A. 35,000 O B. 135,000 © C. 3500 O D. 235,000 > 1st attempt M D . O Oct 13

Chapter 11 Solutions

Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)

Ch. 11.1 - What is the call stack? What is a stack trace?Ch. 11.1 - Prob. 11.12CPCh. 11.1 - Prob. 11.13CPCh. 11.1 - Prob. 11.14CPCh. 11.2 - What does the throw statement do?Ch. 11.2 - Prob. 11.16CPCh. 11.2 - Prob. 11.17CPCh. 11.2 - Prob. 11.18CPCh. 11.2 - Prob. 11.19CPCh. 11.3 - What is the difference between a text file and a...Ch. 11.3 - What classes do you use to write output to a...Ch. 11.3 - Prob. 11.22CPCh. 11.3 - What class do you use to work with random access...Ch. 11.3 - What are the two modes that a random access file...Ch. 11.3 - Prob. 11.25CPCh. 11 - Prob. 1MCCh. 11 - Prob. 2MCCh. 11 - Prob. 3MCCh. 11 - Prob. 4MCCh. 11 - FileNotFoundException inherits from __________. a....Ch. 11 - Prob. 6MCCh. 11 - Prob. 7MCCh. 11 - Prob. 8MCCh. 11 - Prob. 9MCCh. 11 - Prob. 10MCCh. 11 - Prob. 11MCCh. 11 - Prob. 12MCCh. 11 - Prob. 13MCCh. 11 - Prob. 14MCCh. 11 - Prob. 15MCCh. 11 - This is the process of converting an object to a...Ch. 11 - Prob. 17TFCh. 11 - Prob. 18TFCh. 11 - Prob. 19TFCh. 11 - True or False: You cannot have more than one catch...Ch. 11 - Prob. 21TFCh. 11 - Prob. 22TFCh. 11 - Prob. 23TFCh. 11 - Prob. 24TFCh. 11 - Find the error in each of the following code...Ch. 11 - // Assume inputFile references a Scanner object,...Ch. 11 - Prob. 3FTECh. 11 - Prob. 1AWCh. 11 - Prob. 2AWCh. 11 - Prob. 3AWCh. 11 - Prob. 4AWCh. 11 - Prob. 5AWCh. 11 - Prob. 6AWCh. 11 - The method getValueFromFile is public and returns...Ch. 11 - Prob. 8AWCh. 11 - Write a statement that creates an object that can...Ch. 11 - Write a statement that opens the file...Ch. 11 - Assume that the reference variable r refers to a...Ch. 11 - Prob. 1SACh. 11 - Prob. 2SACh. 11 - Prob. 3SACh. 11 - Prob. 4SACh. 11 - Prob. 5SACh. 11 - Prob. 6SACh. 11 - What types of objects can be thrown?Ch. 11 - Prob. 8SACh. 11 - Prob. 9SACh. 11 - Prob. 10SACh. 11 - What is the difference between a text file and a...Ch. 11 - What is the difference between a sequential access...Ch. 11 - What happens when you serialize an object? What...Ch. 11 - TestScores Class Write a class named TestScores....Ch. 11 - Prob. 2PCCh. 11 - Prob. 3PCCh. 11 - Prob. 4PCCh. 11 - Prob. 5PCCh. 11 - FileArray Class Design a class that has a static...Ch. 11 - File Encryption Filter File encryption is the...Ch. 11 - File Decryption Filter Write a program that...Ch. 11 - TestScores Modification for Serialization Modify...Ch. 11 - Prob. 10PC
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