1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
BARSIC [14]
3 years ago
6

3.26 LAB: Leap Year A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate a

round the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are: 1) The year must be divisible by 4 2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400 Some example leap years are 1600, 1712, and 2016. Write a program that takes in a year and determines whether that year is a leap year. Ex: If the input is: 1712 the output is: 1712 - leap year
Computers and Technology
2 answers:
Tju [1.3M]3 years ago
8 0

Answer:

year = int(input("Enter a year: "))

if (year % 4) == 0:

  if (year % 100) == 0:

      if (year % 400) == 0:

          print(str(year) + " - leap year")

      else:

          print(str(year) +" - not a leap year")

  else:

      print(str(year) + " - leap year")

else:

  print(str(year) + "- not a leap year")

Explanation:

*The code is in Python.

Ask the user to enter a year

Check if the <u>year mod 4</u> is 0 or not. If it is not 0, then the year is not a leap year. If it is 0 and if the <u>year mod 100</u> is not 0, then the year is a leap year. If the <u>year mod 100</u> is 0, also check if the <u>year mod 400</u> is 0 or not. If it is 0, then the year is a leap year. Otherwise, the year is not a leap year.

castortr0y [4]3 years ago
6 0

Answer:

i_year=int(input(""))

#check leap year

if((i_year % 4 == 0 and i_year % 100 != 0) or (i_year % 400 == 0)):

  print("{} is a leap year.".format(i_year))

else:

  print("{} is not a leap year.".format(i_year))

Explanation:

You might be interested in
Need help fast this is do a 4
Stells [14]

Answer:

I believe the answer is B.

8 0
3 years ago
How to make python coding do addition
ad-work [718]
Do you mean with the computer
3 0
3 years ago
Can someone help me on how to start this essay?
mezya [45]

Answer:

Start off with an interesting introduction (add questions) make it interesting.

6 0
3 years ago
Read 2 more answers
In a database, data is stored in spreadsheets which have rows and columns.
Tcecarenko [31]
The answer is A. True.
5 0
3 years ago
Energy consumption is measured in units of kilowatt hours (kWh). The more kWh a household use in a month, the higher the energy
3241004551 [841]

Answer:

The c# program for the scenario is given below.

using System;

public class Program {

 double total = 0;

 static void Main() {

     Program ob = new Program();

   Console.WriteLine("Enter total energy used in kilo watts ");

   int p;

   p = Convert.ToInt32(Console.ReadLine());

   ob.bill_calculator(p);

   Console.WriteLine("Total charge for " + p + " kilo watts of energy is " + ob.total);

 }

 public void bill_calculator(int e)

 {

     int first=500;

     double chg_one = 0.12, chg_two=0.15;

     if(e <= 500)

     {      

         total = (e * chg_one);

     }

     else if(e > 500)

     {

         total = ( first * chg_one);

         total = total + ((e-first) * chg_two);

     }

 }

}

 

OUTPUT

Enter total energy used in kilo watts                                                                                                          

5555                                                                                                                                          

Total charge for 5555 kilo watts of energy is 818.25

Explanation:

The program is designed to take user input but does not implements validation for the user input.

The program works as follows.

1. Inside main(), the user enters the energy consumed in kilo watts.

2. This is stored in the integer variable, p.

3. The method bill_calculator() is called which accepts the value of p as a parameter.

4. If the energy used is 500 or less kilo watts, charges are different. While for the amount of energy consumption for more than 500, charges are different.

5. The charges for both, 500 and less and more than 500 are stored in double variables.

6. The if-else statements are used to calculate the total charge based on the amount of power used.

if(e <= 500)

     {      

         total = (e * chg_one);

     }

     else if(e > 500)

     {

         total = ( first * chg_one);

         total = total + ((e-first) * chg_two);

     }

7. Since c# is an object-oriented programming language, any method outside main() is called using the object of the class. All code is written inside the class.

8. Next, the total charge is displayed by calling the bill_calculator() method through the object of the Program class.

9. The main() function has only void return type and hence, no value is returned.

7 0
3 years ago
Other questions:
  • Write the definition of a function named rcopy that reads all the strings remaining to be read in standard input and displays th
    6·1 answer
  • Whenyou connect two batteries in a series, you add the voltages available in each battery and get the total voltage available to
    5·1 answer
  • 40 POINTS I NEED THESE ANSWERS ASAP GIVE ME THE RIGHT ASNWER AND ILL PUT YOU AS THE BRAINLIEST
    13·1 answer
  • Corinne is taking a chemistry class in college. A lab assignment asks students to track the melting point of ten different subst
    8·1 answer
  • Write a C++ program that overloads a function named LinearSearch that searches an array of data of either integer data type, flo
    8·1 answer
  • Chapter 7 presents a comparative analysis of various tools useful in policy making. Select two tools described in chapter 7 from
    12·1 answer
  • What is the function of control unit? in computer. <br>​
    8·1 answer
  • Suppose we want an error correcting code that will allow all single-bit errors to be corrected for memory words of length 15. 1.
    5·1 answer
  • Software piracy can be described as
    10·1 answer
  • Write a function to take three integers x, y and n and check if x and y are both fall between 0 to n-1. If yes, your function sh
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!