Wj 1103a Module1 Exercise2

  • Uploaded by: Rajani Ramsagar
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Wj 1103a Module1 Exercise2 as PDF for free.

More details

  • Words: 160
  • Pages: 1
Exercise 2: Using the switch Construct The objective of this exercise is to practice using the switch construct in decision-making programs.

Task 1 – Writing a Class That Uses a Switch Statement In this task, you write a class called DateThree that uses switch statements to display the day of the week based on the value of a variable. 1. Go to the opsdec directory. 2. Create a class called DateThree with one variable containing a value from 1 to 7, where: • The number 1 represents Monday (beginning of the week). • The number 7 represents Sunday (end of the week). 3. In the DateThree class, create a displayDay method that uses a switch construct to inspect the value for the number of days and displays the corresponding day of the week. The displayDay method should also display an error message if an invalid number is used. 4. Compile and execute your program using the provided DateThreeTest class file.

Related Documents


More Documents from "Rajani Ramsagar"