Click here to Skip to main content
15,895,256 members

Could you check if right

Member 9396865 asked:

Open original thread
THis is the assignment:
Write a program that does the following:

Declare a set of seven integer constants named MONDAY, TUESDAY, ... , SUNDAY. Set MONDAY to 1, TUESDAY to 2, and so forth. Then, create an integer variable named day_of_week and initialize it with some integer value. If the value of day_of_week is 1, the program should display Today is Monday. If the value is 7, the program should display Today is Sunday, and so forth. If the value is not in the range 1-7, the program should display the message Invalid Data. Use a switch construct and the defined constants.

This is what I did could you check?

C#
public class DaysOfWeek

{
    public static void main (String [] args)
    {

        int Monday=1;
        int tuesday=2;
        int wednesday=3;
        int thursday=4;
        int friday=5;
        int saturday=6;
        int sunday=7;
        int day_of_week = 1;


         switch(day_of_week)

         {
          case 1:
            System.out.println("today is monday");
            break;

          case 2:
            System.out.println("today is tuesday");
            break;

          case 3:
            System.out.println("today is wednesday");
            break;

          case 4:
            System.out.println("today is thursday");
            break;

          case 5:
            System.out.println("today is friday");
            break;

          case 6:
            System.out.println("today is saturday");
            break;

          case 7:
            System.out.println("today is sunday");
            break;

          default:
            System.out.println("Invalid Data");
            break;
         }
    }
}
Tags: Java

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900