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
Katarina [22]
2 years ago
6

Question 1. (50 points) 1.Write a program that computes information related to a sequence of entries regarding age of customers.

The user is asked to enter the age of each customer until they wish to stop. The program then computes and displays the following:2. The number of customers in total and in each age group3. The average age for all customers.4. The youngest and oldest customer.4. The range of age (range = highest– lowest). 5. The average age for each age catego
Computers and Technology
1 answer:
schepotkina [342]2 years ago
7 0

Answer:

The solution code is written in Python 3:

  1. count = 0
  2. totalAge = 0
  3. group1_count = 0    #age < 10
  4. group2_count = 0    #age 10 - 20
  5. group3_count = 0    #age 20 - 40
  6. group4_count = 0    #age > 40
  7. group1_total = 0    #subtotal age <= 10
  8. group2_total = 0    #subtotal age 11 - 20  
  9. group3_total = 0    #subtotal age 21 - 40  
  10. group4_total = 0    #subtotal age > 40
  11. age = int(input("Input an age: "))
  12. youngest = age
  13. oldest = age
  14. while(age != -1):
  15.    count += 1
  16.    totalAge += age
  17.    
  18.    if(age <= 10):
  19.        group1_count += 1
  20.        group1_total += age
  21.    elif(age <= 20):
  22.        group2_count += 1
  23.        group2_total += age
  24.    elif(age <= 40):
  25.        group3_count += 1
  26.        group3_total += age
  27.    else:
  28.        group4_count += 1
  29.        group4_total += age
  30.    if(youngest > age):
  31.        youngest = age  
  32.    
  33.    if(oldest < age):
  34.        oldest = age  
  35.    age = int(input("Input an age: "))
  36.    
  37. totalCustomer = count  
  38. avgAge = totalAge / count  
  39. rangeAge = oldest - youngest  
  40. avgAgeGroup1 = group1_total / group1_count  
  41. avgAgeGroup2 = group2_total / group2_count  
  42. avgAgeGroup3 = group3_total / group3_count  
  43. avgAgeGroup4 = group4_total / group4_count  
  44. print("The total number of customers: " + str(totalCustomer))
  45. print("Total number of customer in Group 1 (<=10): " + str(group1_count))
  46. print("Total number of customer in Group 2 (11 - 20): " + str(group2_count))
  47. print("Total number of customer in Group 3 (21 - 40): " + str(group3_count))
  48. print("Total number of customer in Group 4 (> 40): " + str(group4_count))
  49. print("Average age for all customer: " + str(avgAge))
  50. print("Youngest age: " + str(youngest))
  51. print("Oldest age: " + str(oldest))
  52. print("The range of age: " + str(rangeAge))
  53. print("Average age for group 1 (<=10): " + str(avgAgeGroup1))
  54. print("Average age for group 2 (11 - 20): " + str(avgAgeGroup2))
  55. print("Average age for group 3 (21 - 40): " + str(avgAgeGroup3))
  56. print("Average age for group 4 (> 40): " + str(avgAgeGroup4))

Explanation:

Firstly, create the counter variables (e.g. count, group1_count, group2_count etc ) to track the total number of customer and number in each age group. Besides, create variables to hold the value of total of age and sub-total of each age group (Line 1 - 10). We presume there are only four age groups.

Next, prompt user to input the first age (Line 12)

Create variable youngest and oldest to track the lowest and highest age (Line 13 -14). At the moment, set the first input age as value of youngest and oldest.

Create a while loop with sentinel value  -1 (Line 16). Within the loop, track the customer occurrence by incrementing counter variables by one (Line 17, 21, 24, 27 & 30). At the same time, add the current input age to totalAge and to group total (Line 18, 22, 25, 28, & 31).

If the current youngest value is bigger than the current input age, we set the current age to youngest (Line 33- 34).

If the current oldest value is smaller than the current input age, we set the current age to oldest (Line 36- 37).

After terminating the loop with -1, calculate the average age for all customers and for each age group and the range of age (Line 42- 48)  

At last, display all the required calculation results using print function (50 - 62)

You might be interested in
3. Which of the following is a single piece of information related to the person, place,
stepan [7]
I think the answer is field
8 0
3 years ago
Read 2 more answers
What are some reasons DNS is necessary? Check all that apply. A. It maps local addresses to simple names without editing hosts f
dsp73
Domain Name Servers (DNS) are certainly necessary for easy access of resources across a network. The applicable options of the above are A and B - below are explanations as to why.

A: Computers generally are set to automatically obtain DNS information from the network they are connected to or can be pointed to a specific DNS server. This allows for records of where resources (network attach storage devices, other computers on local network, or even website server details) are located on a “master” kind of list so that the local machine’s host file does not have to be routinely updated to contain new addresses.

B: DNS, as explained partially by the answer to A, maintains a type-able or “human readable” domain name for the actual server’s IP address so we don’t have to memorize or keep a list of IPs for where we want to visit on the web (although, Google’s 8.8.8.8 IP address does make it easy). It shows an association between a name/domain name and an IP address so that we can enter something simple (Google.com) and the computer knows where to go (the server at IP address 8.8.8.8) so it can show you the content you want to see.

C: DNS would only simplify remote access if your were attempting LAN (Local Area Network) remote access of another computer on your network. DNS would not make it easier for remote access of a computer on the internet, as most DNS used in non-commercial settings are created and maintained by third-parties that will not put a specific record for one of your computers in it - not that you would want them to either, since it could lead to an open cyber attack.

D: Network throughput is a fancy phrase for network speed. It could be possible that different DNS servers could process requests faster than others, but it is not likely to increase network speed on the whole as navigating via IP or DNS records will be relatively the same speed.
3 0
2 years ago
A company is executing a strategy to encrypt and sign all proprietary data in transit. The company recently deployed PKI service
Softa [21]

Answer:

A. S/MIME

B. TLS

C. Kerberos

Explanation:

PKI : Public Key Infrastructure is a technique which will allow services or applications to communicate securely across the unsecured network or internet.

PKI mainly consist of CA or Certificate Authority who can issue digital certificates or they are also known as trusted CA.  exmaples are godaddy, digicert, verizone, symmantec, etc.. and RA also known as Registration Authorities and they verify if the requested certificates can be stored at CA. Keys will be stored in the central directory.It will also consists of certificate management system and the policies governing PKI.

S/MIME : Secure/Multipurpose Internet Mail Extensions which use assymentric cryptography and sign the MIME data.   S/MIME will provide services like  Authentication, Encryption , Integrity, Privacy and Non repudiation for messaging applications

SMIME uses certificates which can be self signed or CA certified. It specifies MIME type as  application/pkcs7-mime  while transmitting the data.

TLS : Transport Layer Security. the earlier versions used to be known as SSL ( Secure Socket Layer) SSLv3 got depreciated and TLSv1.2/1.3 are popularly used to provide encryption, authentication, Integrity and Hashing for client to server side communication.

Most of the applications communicate securely using TLS.  They will establish secure TCP connection using SSL Handshake. During the Handshake they will exchange supported versions, ciphersuites and certificates. Applications which uses TLS always uses CA certificates and Inhouse applications can communicate using self signed certificate or even with CA certificates.

HTTPS which is also known as HTTP over SSL is widely used for almost all the web services to communicate securely across the internet.

Kerberos : It is a protocol used to prove the identity for two nodes which are communicating with each other. Kerberos uses both symmetric key cryptography and assymetric key cryptography. However, symmetric key cryptography is used widely and public key cryptography is used optionally.

Authentication server which is also known as AS is used to authenticate the requesting client.  It further forwards the user credentials to key distribution center. KDC further issues to TGT ( ticket granting ticket) and it uses TGS's secret key to encrypt. User will receive a encrypted output.  

When a User Login then The client authenticates itself to the Authentication Server (AS) which forwards the username to a key distribution center (KDC). The KDC issues a ticket-granting ticket (TGT), which is time stamped and encrypts it using the ticket-granting service's (TGS) secret key and returns the encrypted result to the user's workstation. Sessions will be renewed and managed by users session manager.

4 0
2 years ago
Sergio knows that to meet the project requirements, it is essential to have
zhenek [66]

Answer:

I need a better explanation??

4 0
3 years ago
I have a computer teacher who made me lose points in an assignment and saying that the reference page should be on a separate pa
lukranit [14]

Answer:

Have a talk with your teacher. Ask why she doesn't believe you, and if it still doesn't work, have a talk with someone that can physically help you - a principle or another teacher may be the best solution.

4 0
3 years ago
Other questions:
  • Which of the following is the rarest and most valuable mineral ore among the native elements?
    13·1 answer
  • When a typist changes from a conventional typewriter to a word processor, his typing schema will have to _____ to incorporate th
    12·1 answer
  • How many seconds are required to make a left turn and join traffic?​
    11·2 answers
  • Write a public interface named Test with the following behavior:
    5·1 answer
  • Which of the following is a school-to-work program that provides the student with paid employment, school credit, and school gra
    7·2 answers
  • Application means to
    5·1 answer
  • The ____________ mechanism consists of a lever arm attached to the mousetrap spring.
    15·1 answer
  • The current annual interest rate is 5 percent, and you are taking out a 20-year loan with a monthly end-of-month payment. If you
    5·1 answer
  • When did time begin?
    11·1 answer
  • A(n) _____ is a data validation rule that should be applied to mandatory data items.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!