You can determine whether a year is a leap year by testing if it is divisible by 4.
However, years that are also divisible by 100 are not leap years, unless they are
also divisible by 400, in which case they are leap years. Write a script that
allows a user to enter a year and then determine whether the year entered is a
leap year. Include a form with a single text box where the user can enter a year.
Display an alert dialog box to the user stating whether the year they entered is a
standard year or a leap year.
8 3894
Please help me solve this problem
You can determine whether a year is a leap year by testing if it is divisible by 4.
However, years that are also divisible by 100 are not leap years, unless they are
also divisible by 400, in which case they are leap years. Write a script that
allows a user to enter a year and then determine whether the year entered is a
leap year. Include a form with a single text box where the user can enter a year.
Display an alert dialog box to the user stating whether the year they entered is a
standard year or a leap year.
my email address is **** - email removed by MODERATOR
epots9 1,351
Recognized Expert Top Contributor
Please help me solve this problem.
Using Javascript, I must solve this.
The interface consits of a text box where a year to be tested is entered, a Check for leap year botton. operation, a user enters a year to test and clicks the button a message must appear stating that year is a standard year or a leap year.
(using javascript to solve)
You can determine whether a year is a leap year by testing if it is divisible by 4.
However, years that are also divisible by 100 are not leap years, unless they are
also divisible by 400, in which case they are leap years. Write a script that
allows a user to enter a year and then determine whether the year entered is a
leap year. Include a form with a single text box where the user can enter a year.
Display an alert dialog box to the user stating whether the year they entered is a
standard year or a leap year.
my e-mail address is **** - email removed
Posting Homework or Coursework Questions and Answers
first attempt the question and then post parts of your code where u need help with and then we can hlep u.
<html>
<head>
<script language="javas cript">
<!--Hide from old browsers
function valYear(myform) {
var Year = document.Leap.Y ear.value
if (Year == " ") {
alert("Please enter the year you want to test.")
document.Leap.Y ear.value = " "
document.Leap.Y ear.focus()
}
}
//-->
</script>
<title>Leap Year Test</title>
</head>
<body>
<form name="Leap">
<table>
<tr>
<td>Year: <input Type="text" name="Year" size="18"></td>
</tr>
<tr>
<td><input Type="Button" value="Check for leap year" onclick="valYea r(Leap)"></td>
</tr>
</table>
</form>
</body>
</html>
This is the code form my problem.
epots9 1,351
Recognized Expert Top Contributor
use: -
var leap = Year % 4;
-
if (leap == 0)
-
{
-
//its a leap year code
-
}
-
else
-
{
-
//its not a leap year code
-
}
-
u just need to finish it off, to do whatever u need it to do.
good luck
acoder 16,027
Recognized Expert Moderator MVP
Merged three threads. As you were informed previously - do not double/triple post.
use: -
var leap = Year % 4;
-
if (leap == 0)
-
{
-
//its a leap year code
-
}
-
else
-
{
-
//its not a leap year code
-
}
-
u just need to finish it off, to do whatever u need it to do.
good luck
Thanks Problem solved
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dr John Stockton |
last post by:
I'm starting a new thread, for clarity.
I'm assuming that it's ECMA-262 3rd Edn (1999) that we should be using
for Web pages; that 4th Edn (what's its present status? is it
available?) is too advanced for compatibility with many browsers in
present-day use; that Web authors should be aware of what JScript and
..NET may do, but cannot rely...
|
by: deepak.rathore |
last post by:
can someone give the regular expr. to validate leap yr like
02/29/2000,02/29/00
Thanks
|
by: owz |
last post by:
Ok, I am making a program (java class file) 2 work out if a date entered is valid or invalid for the day, month year, and for leap years.. dd/mm/yyyy .
I seem 2 have gotten it 2 validate the year and month, but my code errors on the day validation.
Error(91,38): variable daysInMonth might not have been initialized.
Any thoughts, all help...
|
by: rn216_ccc |
last post by:
Hi there all,
I found a web site,. http://www.onlineconversion.com/leapyear.htm,
where it can give a list of leap years by within the given range by
the user, or the user may enter a year and the program will make the
decision if it is a leap year or not. In addition, I kind of
understand that there are certain rules to calculating leap...
|
by: Brigitte Behrmann |
last post by:
Can anyone assist with my code. I just cannot get this to work:
I have to write a script that allows the user to enter a year & then determine whether it is a leap year or not. The request is for a form with a single text box and using an alert dialog box stating if the entered year is a standard or leap year.
Code so far:
<HTML>
<HEAD>...
| |
by: cybermom |
last post by:
Hi another newbie here
I am trying to get the message: The you entered is a leap year, but it does not happen, what did I do wrong with this script?
<html>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--hide from old browsers
|
by: mazwolfe |
last post by:
I'm new here, so excuse me if my style is incorrect. Can anyone come
up with a better method for this calculation?
Code:
int is_leap(int year)
{
switch (year % 19) {
case 0: case 3: case 6: case 8:
case 11: case 14: case 17: return 1;
default: return 0;
|
by: jimix |
last post by:
here's what i have. using microsoft studio
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
int main( void )
{
int year, b, c, e;
b = 4;
c = 100;
|
by: jrw133 |
last post by:
Hello. So im a little bit stuck on one of my homework questions.
heres the question:
Write a C Shell Script that performs the following functions. Asks the user to input a year. The script should then calculate whether or not the year is a leap year. The script should caculate whether or not it is a leap year using the following algorithm. ...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |