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
olga_2 [115]
3 years ago
8

Write a program that asks the user to enter a date in MM/DD/YYYY format that is typical for the US, the Philippines, Palau, Cana

da, and Micronesia. For the convenience of users from other nations, the program computes and displays this date in an alternative DD.MM.YYYY format. Sample run of your program would look like this: Please enter date in MM/DD/YYYY format: 7/4/1776 Here is the formatted date: 04.07.1776 You can assume that the user will enter correctly formatted date, but do not count on having 0s in front of one-digit dates. Hint: you will need to use string addition (concatenation) here.
Computers and Technology
1 answer:
stepladder [879]3 years ago
8 0

Answer:

In Python:

txt = input("Date in MM/DD/YYYY format: ")

x = txt.split("/")

date=x[1]+"."

if(int(x[1])<10):

   if not(x[1][0]=="0"):

       date="0"+x[1]+"."

   else:

       date=x[1]+"."

   

if(int(x[0])<10):

   if not(x[0][0]=="0"):

       date+="0"+x[0]+"."+x[2]

   else:

       date+=x[0]+"."+x[2]

else:

   date+=x[0]+"."+x[2]

   

print(date)

Explanation:

From the question, we understand that the input is in MM/DD/YYYY format and the output is in DD/MM/YYYY format/

The program explanation is as follows:

This prompts the user for date in MM/DD/YYYY format

txt = input("Date in MM/DD/YYYY format: ")

This splits the texts into units (MM, DD and YYYY)

x = txt.split("/")

This calculates the DD of the output

date=x[1]+"."

This checks if the DD is less than 10 (i..e 1 or 01 to 9 or 09)

if(int(x[1])<10):

If true, this checks if the first digit of DD is not 0.

   if not(x[1][0]=="0"):

If true, the prefix 0 is added to DD

       date="0"+x[1]+"."

   else:

If otherwise, no 0 is added to DD

       date=x[1]+"."

   

This checks if the MM is less than 10 (i..e 1 or 01 to 9 or 09)

if(int(x[0])<10):

If true, this checks if the first digit of MM is not 0.

   if not(x[0][0]=="0"):

If true, the prefix 0 is added to MM and the full date is generated

       date+="0"+x[0]+"."+x[2]

   else:

If otherwise, no 0 is added to MM and the full date is generated

       date+=x[0]+"."+x[2]

else:

If MM is greater than 10, no operation is carried out before the date is generated

   date+=x[0]+"."+x[2]

This prints the new date

print(date)

You might be interested in
In a print statement, you can set the ________ argument to a space or empty string to stop the output from advancing to a new li
cluponka [151]
The answer to the question is end
5 0
3 years ago
I need help please!!!!
MissTica
Just restart it and it will be fixed
5 0
3 years ago
Read 2 more answers
Pls help.
melisa1 [442]

Answer:

First one would be work ethic.

Second one would be communication.

Third one would be adaptability.

Fourth one would be creativity.

(These are all guesses tho, so i'm not 100% sure !!)

Explanation:

6 0
3 years ago
Read 2 more answers
Name at least three classes to which each of these objects might belong:
deff fn [24]
Cooking class and history and the other one I don’t know
4 0
3 years ago
Create class SavingsAccount. Use a static variable annualInterestRate to store the annual interest rate for all account holders.
emmasim [6.3K]

Answer:

Class SavingsAccount( ):

annual_interest_rate

def.__init__(self, savings_balance):

self.savingsBalance = savings_balance

def calculatMonthlyInterest( ):

self.savingsBalance += (self.savingsBalance * annual_interest_rate) /12

return self.savingsBalance

def setInterestRate_(self, value):

self.annual_interest_rate = value

Explanation:

The python class above is used to create a savings account data for a customer, with methods to change the static interest rate and to calculate the monthly interest rate.

8 0
4 years ago
Other questions:
  • What kind of operating system is Windows? Command-line Browser based Graphical user interface Linux-based
    10·2 answers
  • If you were asked to subnet a network in such a way as to arrive at 6 network ids you would need to borrow 2 bits.
    7·1 answer
  • The network layer, or osi layer 3, provides services to allow end devices to exchange data across the network. to accomplish thi
    15·1 answer
  • Select the correct answer.
    5·1 answer
  • In GamePoints' constructor, assign teamWhales with 500 and teamLions with 500. #include using namespace std; class GamePoints {
    13·1 answer
  • Two positive outcomes generally associated with modern computing are greater _____.
    12·2 answers
  • E-mail is an temporary message medium.<br> a. True<br> b. False
    5·2 answers
  • Ten examples of an interpreter
    8·1 answer
  • Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segme
    9·1 answer
  • The main difference between \f and \r is that \f produces a
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!