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
Illusion [34]
2 years ago
9

Write a program that prints the day number of the year, given the date in the form month-day-year. For example, if the input is

1-1-2006, the day number is 1; if the input is 12-25-2006, the day number is 359. The program should check for a leap year. A year is a leap year if it is divisible by 4, but not divisible by 100. For example, 1992 and 2008 are divisible by 4, but not by 100. A year that is divisible by 100 is a leap year if it is also divisible by 400. For example, 1600 and 2000 are divisible by 400. However, 1800 is not a leap year because 1800 is not divisible by 400.
Computers and Technology
1 answer:
vlabodo [156]2 years ago
4 0

Answer:

C++:

C++ Code:

#include <iostream>

#include <string>

using namespace std;

struct date

{

  int d,m,y;

};

int isLeap(int y)

{

  if(y%100==0)

  {

      if(y%400==0)

      return 1;

      return 0;

  }

  if(y%4==0)

  return 1;

  return 0;

}

int day_no(date D)

{

  int m = D.m;

  int y = D.y;

  int d = D.d;

  int i;

  int mn[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

  for(i=0;i<m;i++)

  {

      d += mn[i];

  }

  if(isLeap(y))

  {

      if(m>2)

      d++;

  }

  return d;

}

date get_info(string s)

{

  date D;

  int i,p1,p2,l = s.length();

  for(i=0;i<l;i++)

  {

      if(s[i] == '-')

      {

      p1 = i;

      break ;

      }

  }

  for(i=p1+1;i<l;i++)

  {

      if(s[i] == '-')

      {

      p2 = i;

      break ;

      }

  }

 

  D.m = 0;

  for(i=0;i<p1;i++)

  D.m = (D.m)*10 + (s[i]-'0');

 

  D.d = 0;

  for(i=p1+1;i<p2;i++)

  D.d = (D.d)*10 + (s[i]-'0');

 

  D.y = 0;

  for(i=p2+1;i<l;i++)

  D.y = (D.y)*10 + (s[i]-'0');

 

  return D;

 

}

int main()

{

  string s1 = "4-5-2008";

  string s2 = "12-30-1995";

  string s3 = "6-21-2000";

  string s4 = "1-31-1500";

  string s5 = "7-19-1983";

  string s6 = "2-29-1976";

 

  cout<<"Date\t\tDay no\n\n";

  cout<<s1<<"\t"<<day_no(get_info(s1))<<endl;

  cout<<s2<<"\t"<<day_no(get_info(s2))<<endl;

  cout<<s3<<"\t"<<day_no(get_info(s3))<<endl;

  cout<<s4<<"\t"<<day_no(get_info(s4))<<endl;

  cout<<s5<<"\t"<<day_no(get_info(s5))<<endl;

  cout<<s6<<"\t"<<day_no(get_info(s6))<<endl;

 

 

  return 0;

}

Explanation:

You might be interested in
1. Grade data is:
horrorfan [7]

Answer:

1.)

import math

def min_max(lst):

   minimum = math.inf

   maximum = -math.inf

   for x in lst:

       if minimum > x:

           minimum = x

       elif maximum < x:

           maximum = x

   return minimum, maximum

2.)

def deltaGrade(lst):

   sm = 0  #sm is sum

   for x in lst:

       sm += x

   mean = sm/len(lst)

   deltaG = 75 - mean

   return deltaG

7 0
3 years ago
Which are the best examples of cost that should be considered when creating a project budget
sashaice [31]

Explanation:

how much the project will cost

5 0
3 years ago
____ software is used to block unwanted e-mail and is available at many levels.
Anika [276]
Anti-spam <span>software is used to block unwanted e-mail and is available at many levels.</span>
3 0
3 years ago
How to remove special formatting from a table in word.
ch4aika [34]

Answer:

Clear Format

Explanation:

7 0
1 year ago
The protection of the confidentiality, integrity, and availability of information assets, whether in storage, processing, or tra
Sergeu [11.5K]

Answer: Information security

Explanation:

 The information security is one of the system that keeps the data confidential, assure the integrity and also availability of the information or data.

This system is basically refers as the CIA triad in the information security system and the data risk management.

The main aim of the information security is that keeps the data protected from the unauthorized accessing and also  controlling the access in the system.

Therefore, Information security is the correct answer.

8 0
3 years ago
Other questions:
  • Write a program that calls fork(). Before calling fork(), have the main process access a variable (e.g., x) and set its value to
    5·1 answer
  • What precaution can you take while using a social networking site to prevent a data breach?
    15·1 answer
  • Explain what occurs when you synchronize computer and mobile devices.
    5·1 answer
  • 3. Find the product of (a² +3a+5) x (a+7)​
    7·1 answer
  • A(n) ____ string contacts the data source and establishes a connection with the database using the Data Source Configuration Wiz
    5·1 answer
  • Different network devices function at different network communication layers, depending on their purpose. Using the TCP/IP model
    5·1 answer
  • The design of a blog refers to:
    8·1 answer
  • The average price of milk increased from $3.00 last year to $3.50 this year. This is most likely due to:
    14·1 answer
  • Tim is a project manager. He is brainstorming with his team about problems that could arise during the next phase of the project
    5·1 answer
  • Pleaseeeee helpppppppp​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!