Tuesday, 17 July 2018

11-C Program-7 Write a program to input number of week days (1-7) and translate to its equivalent name of the week. (1 to Monday, 2 to Tuesday……7 to Sunday)*/

#7.Write a program to input number of week days (1-7) and translate to its #equivalent name of the week. (1 to Monday, 2 to Tuesday……7 to Sunday)

Algorithim:
Input:
1.n_d (name of the day)
Output:
1. Week of Day (Mon to Sunday as per input)
Method:
1.Start
2. Read n_d
3. Write n_d
4. #logic
  if(n_d == 1)
  begin
     Write "Monday"
 end
 else 
if(n_d == 2)
  begin
     Write "Tuesday"
 end
 else
 if(n_d == 3)
  begin
     Write "Monday"
 end
 else 
  .
  .
  .
if(n_d == 7)
  begin
     Write "Sunday"
 end
 else 
 begin
     Write" Wrong choice:(choose 1 to 7
 end
5.stop

Example:
Enter number of day (1-7)7 Number of Day= 7 The Day is Sunday


#program
 
n_d=int(input("Enter number of day (1-7)"))
print("Number of Day=",n_d)
#logic
if n_d==1:
    print("The Day is Monday")
else:
    if n_d==2:
        print("The Day is Tuesday")
    else:
        if n_d==3:
            print("The Day is Wednesday")
        else:
            if n_d==4:
                print("The Day is Thursday")
            else:
                if n_d==5:
                    print("The Day is Friday")
                else:
                    if n_d==6:
                        print("The Day is Saturday")
                    else:
                        if n_d==7:
                            print("The Day is Sunday")
                        else:
                            print("Wrong Choice enter(1 to 7)") 

 

No comments:

Post a Comment