Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Visual basic your job is to use Select Case Blocks and Do/For Loops to design a

ID: 3603762 • Letter: V

Question

Visual basic

your job is to use Select Case Blocks and Do/For Loops to design a clock and calendar interface. So that we are on the same page, here are some parameters:

You need not make a representation of a clock. All you need to do is output the current time and date (such as 11:16 AM on Thursday October 19, 2017). I am aware that there are functions that do this, but I do not want you to use them directly. Clocks and calendars are the perfect example to build these constructions.

1. Start your program by asking the user to input the current weekday (as a word), month (as a number), day, year, and time (in hours, minutes, seconds, and the AM/PM designation). Each of these individual elements should be entered in a separate spot.

2. Use a select case block to handle the original assignment of a day counter from the weekday entered. Sunday should be 0, Monday 1, etc. You will use this counter and a Mod function to determine for the future which weekday it is.

3. Determine if it is a leap year. If it is divisible by 4, then it is.

4. Write a select case block that manages how many days the current month has. Remember that for February, this is dependent upon whether or not it is a leap year.

5. Since a clock runs indefinitely, the entire process after the initial entry should be a Do Loop (which serves the purpose of the years). Make this Do Loop a subroutine so that the inputs must come first.

6. Since the mechanisms of a clock and a calendar are finitely driven (they have predictable ends), these should be managed by a nested For Loop. The order in which the nesting should occur should be year, month, day, hour, minute, second.

7. For reference, here are the bounds:
-Months have variable numbers of days: January - 31, February - 28 (29 in leap year), March - 31, April - 30, May - 31, June - 30, July - 31, August - 31, September - 30, October - 31, November - 30, December - 31
-A day has 24 hours. AM and PM flips on the attainment of 12 (12 AM is midnight, 12 PM is noon)
-An hour has 60 minutes
-A minute has 60 seconds

Use the following to manage a second:

Start the clock by using a button. The button when you code it will contain all of the code. Normally a button will have an action that will start with Private Sub ...

Start the button instead with this: Private Async Sub ... (so in other words, type Async in between Private and Sub on your button)

Now, just to clarify (as I have had people get tripped up on this):

The whole process within the button (after the population of the current time) is a Do Loop. WITHIN that Do Loop, you will have a group of For Loops. I highly suggest working out the seconds, and then building the loop around it for minutes, and then for hours, etc.

To make your system wait one second, this is the best approach. I misled you, and for that I apologize:

Use the command Await Task.Delay(1000)

This makes it wait exactly one second before anything else occurs.

Hints:  


Manage AM and PM as an IF statement within the loop (when the 12th hour is attained, flip it)

Write your For loop bounds regarding days with an initial value of 1 and a terminal value of numberOfDays. That way, the Select Case Block can help you to only have to handle this once. Do not forget to add one to the initial counter to help you with displaying the correct day of the week.

Your indexing variables will be used to help make decisions (such as how many days the month has, does AM/PM flip, and that the 13th hour of the day is 1 PM). This does not mean that they will be modified, but rather that they will be essential to decisions along the way.

This process will go on and on and on. To end it, just close the form window.

A good way to do this process is iteratively. Start with seconds. Make sure it works. Then build minutes around it. Then build hours around it.

Your for loops will start at the input time. As a consequence, you will need to manage what happens when the end is attained. In other words, you need to reset the subroutine's parameter variables because the index will need that on successive passes of the do loop.

please show code and a screen shot of program

Explanation / Answer

The standard Gregorian Calendar that we follow in our daily life, has a leap year every four years. In such a year the month of February contains one extra day in order to keep the calendar year synchronized with the Astronomical Year. So the number of days in the month of February becomes 29 and the number of days in the leap year becomes 366.

The Rule

The full rule for checking a leap year is not very well known, and I often find many of my juniors and fellow pupils lacking the exact knowledge of the full rule. What most people know is that if the year is divisible by 4 then it is a leap year. But although this rule is good for nearly all practical purposes, it is not the full rule. The exact rule for finding out whether a year is leap year or not, is best described by a flowchart:What prompted me to write the article was the popular misconception to the rule and the ability to demonstrate the boolean reduction technique. The article took shape while I was trying to explain the rule to my brother Bikkhan for the the n-th time and decided to draw the flowchart to make matters easy for him. Lastly, I also figured out that this could be an excellent way of showing him the practical usage of boolean reductions that he has learnt in his Std XI curriculum, but never grasped the true significance