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
levacccp [35]
4 years ago
12

A program that accepts insurance policy data, including a policy number, customer last name, customer first name, age, premium d

ue date (month, day, and year), and number of driver accidents in the last three years. If an entered policy number is not between 1000 and 9999 inclusive, set the policy number to 0. If the month is not between 1 and 12 inclusive, or the day is not correct for the month (for example, not between 1 and 31 for January or 1 and 29 for February), set the month, day, and year to 0. Display the policy data after any revisions have been made.
Computers and Technology
1 answer:
valentina_108 [34]4 years ago
8 0

Answer:

  1. policy_num = int(input("Enter policy number: "))
  2. lastName = input("Enter last name: ")
  3. firstName = input("Enter first name: ")
  4. premiumDate = input("Enter premius due date (mm/dd/yyyy): ")  
  5. numAcc = int(input("Enter number of driver accident in the past three years: "))
  6. if(policy_num <1000 or policy_num > 9999):
  7.    policy_num = 0  
  8. dateComp = premiumDate.split("/")
  9. month = int(dateComp[0])
  10. day = int(dateComp[1])
  11. year = int(dateComp[2])
  12. if(month < 1 or month > 12):
  13.    month = 0
  14.    day = 0
  15.    year = 0  
  16. else:
  17.    if(month == 1 or month == 3 or month == 5 or month == 7 or month == 8 or month == 10 or month == 12):
  18.        if(day < 1 or day > 31):
  19.            month = 0
  20.            day = 0
  21.            year = 0  
  22.    elif(month == 4 or month == 6 or month == 9 or month == 11):
  23.        if(day <1 or day > 30):
  24.            month = 0
  25.            day = 0
  26.            year = 0
  27.    elif(month == 2):
  28.        if(day < 1 or day > 29):
  29.            month = 0
  30.            day = 0
  31.            year = 0
  32. print("Policy number: " + str(policy_num))
  33. print("Last name: " + lastName)
  34. print("First name: " + firstName)
  35. print("Premium Date: " + str(month) + "/" + str(day) + "/" + str(year))
  36. print("Number of driver accidentin the last three years: " + str(numAcc))

Explanation:

The solution code is written in Python 3.

Firstly use input function to prompt user to enter all the necessary insurance policy data (Line 1 - 5).

Next create an if statement to validate the input policy number. If the policy number is not within the range of 1000 - 9999, set the policy number to zero (Line 7 -8).

Next, split the input premium date into month, day and year (Line 10 -13). It is followed by checking the month if it is between 1 - 12. If not, set the month, day and year to zero (Line 15 - 18). Otherwise the program will proceed to validate the month based on the maximum and minimum number of days for a particular month (Line 20 - 34). If the day is out of range, set month, day and year to zero.

Lastly, use print function to display the policy data (Line 36 - 40).

You might be interested in
Write a loop to output the word EXAM 99 times
worty [1.4K]

Answer:

Following are the answer for the given question

for(int i=1;i<=99;++i) // for loop

{

cout<<"EXAM"<<endl; // display the word EXAM

}

Explanation:

In this question we using for loop which is iterating 99 times and print the

word "EXAM  " 99 times.

The variable i is initialized by 1 and check the condition if the condition in loop  is true it will execute the loop and print "EXAM" .The loop will executed 99 times when the condition in loop is false then loop become terminated.

Following are the program in c++

#include<iostream>// header file

using namespace std;

int main() // main method

{

for(int i=1;i<=99;++i) // for loop

{

cout<<"EXAM"<<endl; // display the word EXAM

}

   return 0;

}

3 0
3 years ago
Which option correctly identifies if the researcher’s approach was the best choice in the following scenario and explains why?
Tasya [4]

Answer:

A

Explanation:

go do it

4 0
3 years ago
Read 2 more answers
If you wish to sign out of your Microsoft account, tap or click ____ on the ribbon to open the Backstage view and then tap or cl
lyudmila [28]
If you wish to sign out of your Microsoft account, tap or click file on the ribbon to open the Backstage view and then tap or click the Account tab to <span>display the Account gallery, and tap or click the Sign out link. There are different ways to do that but it is the easiest.</span>
7 0
3 years ago
Suppose list1 is an MyArrayList and list2 is a MyLinkedList. Both contains 1 million double values. Analyze the following code:
hjlf

Answer:

The correct answer for the given question is " The Code fragment A runs fastly than the code fragment of B".

Explanation:

In this question there are some information is missing i. e options. The question does not give any options. The options for the given question is given below

(A.) The Code fragment A runs fastly than the code fragment of B.

(B.) The Code fragment B runs fastly than code fragment of  A.

(C)  The Code fragment A runs as fastly as code fragment of B.  

So we conclude the answer i.e option(A) because As given in the question list1  is a MyArrayList and list2 is a MyLinkedList.  , in list1 we fetching the data easily and fastly means that it remove the data easily as compare to list2 As MyArrayList is storing the list only and also we can fetch the data easily manner.

The list2 is an object of MyLinkedList means that it manipulating the data fastly as compared to MyArrayList but if we compared the fetching of data then  MyArrayList is a better option so the code fragment runs fastly then code fragmented B.

7 0
4 years ago
Why we need to interpret the drawing and plans
scoray [572]

Technical drawing is essential for communicating ideas in industry and engineering.

5 0
3 years ago
Other questions:
  • Write a short java method that takes an integer n and returns the sum of all the odd positive integers less than or equal to n.
    5·1 answer
  • Which is an example of a student practicing ethical behavior online??
    7·2 answers
  • Which two sentences uses the colon correctly?
    13·1 answer
  • Terms that represents the achual speed used by device to transfer data​
    14·1 answer
  • Write a program in c++ that asks the user for a sequence of n​integers, where the user provides the number of elements n​ then e
    12·1 answer
  • Using PowerPoint or Impressed guarantees that your presentation will do which of the following?
    6·1 answer
  • Enum Digits {0, 1};
    10·1 answer
  • Two threads try to acquire the same resource at the same time and both are blocked. Then, they continually change their states i
    14·1 answer
  • Keyshia wants to add movement to her PowerPoint presentation. Which tab should she use to complete this task
    15·2 answers
  • 1. The letters that appear after the dot after a file name are called the:
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!