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
MrRa [10]
4 years ago
12

Write a program named CheckMonth2 that prompts a user to enter a birth month and day. Display an error message that says Invalid

date if the month is invalid (not 1 through 12) or the day is invalid for the month (for example, not between 1 and 31 for January or between 1 and 29 for February). If the month and day are valid, display them with a message. For example, if the month entered is 2, and the day entered is 17, the output should be 2/17 is a valid birthday.
Engineering
1 answer:
bonufazy [111]4 years ago
3 0

Answer:

#Welcome message

print("welcome to CheckMonth2")

#prompting  day and month

day = int(input("Please, add a day: "))

month = int(input("please, add a month: "))

#Defining max number of days per each month

monthly_days = [31,29,31,30,31,30,31,31,30,31,30,31]

#Validating day and month were added properly

if month > 12 or month < 1:

   print("invalid date for the month")

elif day > monthly_days[month-1] or day < 1:

    #Printing error message

   print("invalid date for the month")

else:

   #printing correct message

   print ("{}/{} is a valid birthday".format(day,month))

Explanation:

This code was  made using Python and consists of the following parts:

  • A Welcome message with the name of the code.
  • A line to prompt the day.
  • A line to prompt the month.
  • A list to define the number of day per month. For example, the first posistion of the list corrresponds to the maximum number of days in January, the next is for February and so on.
  • A conditional tests to validate the day and month are in correct. ranges.
  • Output the error message if conditions are not met.
  • Output date if contidios are met.
You might be interested in
Two technicians are discussing a vehicle that cranks slowly when the key is turned to the crank position. The positive battery t
Norma-Jean [14]

Answer:

Both are right

Explanation:

3 0
2 years ago
Write a C++ program to display yearly calendar. You need to use the array defined below in your program. // the first number is
ddd [48]

Answer:

//Annual calendar

#include <iostream>

#include <string>

#include <iomanip>

void month(int numDays, int day)

{

int i;

string weekDays[] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};

// Header print

      cout << "\n----------------------\n";

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

{

cout << left << setw(1) << weekDays[i];

cout << left << setw(1) << "|";

}

cout << left << setw(1) << "|";

      cout << "\n----------------------\n";

      int firstDay = day-1;

      //Space print

      for(int i=1; i< firstDay; i++)

          cout << left << setw(1) << "|" << setw(2) << " ";

      int cellCnt = 0;

      // Iteration of days

      for(int i=1; i<=numDays; i++)

      {

          //Output days

          cout << left << setw(1) << "|" << setw(2) << i;

          cellCnt += 1;

          // New line

          if ((i + firstDay-1) % 7 == 0)

          {

              cout << left << setw(1) << "|";

              cout << "\n----------------------\n";

              cellCnt = 0;

          }

      }

      // Empty cell print

      if (cellCnt != 0)

      {

          // For printing spaces

          for(int i=1; i<7-cellCnt+2; i++)

              cout << left << setw(1) << "|" << setw(2) << " ";

          cout << "\n----------------------\n";

      }

}

int main()

{

int i, day=1;

int yearly[12][2] = {{1,31},{2,28},{3,31},{4,30},{5,31},{6,30},{7,31},{8,31},{9,30},{10,31},{11,30},{12,31}};

string months[] = {"January",

"February",

"March",

"April",

"May",

"June",

"July",

"August",

"September",

"October",

"November",

"December"};

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

{

//Monthly printing

cout << "\n Month: " << months[i] << "\n";

month(yearly[i][1], day);

if(day==7)

{

day = 1;

}

else

{

day = day + 1;

}

cout << "\n";

}

return 0;

}

//end

3 0
4 years ago
When plotting a single AC cycle beginning at zero degrees and moving forward in time the cycles negative peak occurs at
Lana71 [14]

Answer:A 270 degrees

Explanation:

4 0
3 years ago
A gas in a piston–cylinder assembly undergoes a compression process for which the relation between pressure and volume is given
viktelen [127]

Answer:

A.) P = 2bar, W = - 12kJ

B.) P = 0.8 bar, W = - 7.3 kJ

C.) P = 0.608 bar, W = - 6.4kJ

Explanation: Given that the relation between pressure and volume is

PV^n = constant.

That is, P1V1^n = P2V2^n

P1 = P2 × ( V2/V1 )^n

If the initial volume V1 = 0.1 m3,

the final volume V2 = 0.04 m3, and

the final pressure P2 = 2 bar. 

A.) When n = 0

Substitute all the parameters into the formula

(V2/V1)^0 = 1

Therefore, P2 = P1 = 2 bar

Work = ∫ PdV = constant × dV

Work = 2 × 10^5 × [ 0.04 - 0.1 ]

Work = 200000 × - 0.06

Work = - 12000J

Work = - 12 kJ

B.) When n = 1

P1 = 2 × (0.04/0.1)^1

P1 = 2 × 0.4 = 0.8 bar

Work = ∫ PdV = constant × ∫dV/V

Work = P1V1 × ln ( V2/V1 )

Work = 0.8 ×10^5 × 0.1 × ln 0.4

Work = - 7330.3J

Work = -7.33 kJ

C.) When n = 1.3

P1 = 2 × (0.04/0.1)^1.3

P1 = 0.6077 bar

Work = ∫ PdV

Work = (P2V2 - P1V1)/ ( 1 - 1.3 )

Work = (2×10^5×0.04) - (0.608 10^5×0.1)/ ( 1 - 1.3 )

Work = (8000 - 6080)/ -0.3

Work = -1920/0.3

Work = -6400 J

Work = -6.4 kJ

5 0
4 years ago
What type of engineer would be most likely to develop a design for cars? chemical civil materials mechanical
Andreyy89
I don’t know but good luck
4 0
3 years ago
Other questions:
  • Wqqwfqwfqwfqfqfqffqwffqwqfqqfqfqffqqfqfwccc
    12·2 answers
  • Extra Credit: The Linc (parking lot and stadium)In celebration of the upcoming Super Bowl, for a maximum 10 points of extra cred
    7·1 answer
  • If a pendulum takes 2 sec to swing in each direction, find the period and the frequency of the swing
    15·1 answer
  • A well penetrates an unconfined aquifer. Prior to pumping, the water level (head) is 25 meters. After a long period of pumping a
    14·1 answer
  • A square isothermal chip is of width w = 5 mm on a side and is mounted in a substrate such that its side and back surfaces are w
    7·1 answer
  • PLS HURRY!!!
    10·2 answers
  • Consider a machine of mass 70 kg mounted to ground through an isolation system of total stiffness 30,000 N/m, with a measured da
    9·1 answer
  • What is the answer???
    10·1 answer
  • What are the main causes of injuries when using forklifts?
    5·1 answer
  • In a typical American building, most modern lighting systems must use what voltage?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!