Question

In: Computer Science

Exercise 6: Dog Years It is commonly said that one human year is equivalent to 7...

Exercise 6: Dog Years It is commonly said that one human year is equivalent to 7 dog years. However this simple conversion fails to recognize that dogs reach adulthood in approximately two years. As a result, some people believe that it is better to count each of the first two human years as 10.5 dog years, and then count each additional human year as 4 dog years. Write a program that implements the conversion from human years to dog years described in the previous paragraph. Ensure that your program works correctly for conversions of less than two human years and for conversions of two or more human years. Your program should display an appropriate error message if the user enters a negative number.

code by python

Solutions

Expert Solution

Python code:

#accepting number of years
year=int(input("Enter the number of human years: "))
#checking if it negative
if(year<0):
#printing invalid human year
print("Number of human years can't be less than 0")
#checking if year is less than or equal to 2
elif(year<=2):
#printing Number of dog years
print("Number of dog years:",year*10.5)
else:
#printing Number of dog years
print("Number of dog years:",2*10.5+(year-2)*4)


Screenshot:


Input and Output:


Related Solutions

Exercise 4A-9 Equivalent Units; Equivalent Units of Production; Assigning Costs-FIFO Method [LO4-6, LO4-7, LO4-8] Jarvene Corporation...
Exercise 4A-9 Equivalent Units; Equivalent Units of Production; Assigning Costs-FIFO Method [LO4-6, LO4-7, LO4-8] Jarvene Corporation uses the FIFO method in its process costing system. The following data are for the most recent month of operations in one of the company’s processing departments: Units in beginning inventory 350 Units started into production 4,250 Units in ending inventory 330 Units transferred to the next department 4,270 Materials Conversion Percentage completion of beginning inventory 70 % 30 % Percentage completion of ending...
Exercise 7-28 (Algo) Receivables; transaction analysis [LO7-3, 7-5, 7-6, 7-7, 7-8] Weldon Corporation’s fiscal year ends...
Exercise 7-28 (Algo) Receivables; transaction analysis [LO7-3, 7-5, 7-6, 7-7, 7-8] Weldon Corporation’s fiscal year ends December 31. The following is a list of transactions involving receivables that occurred during 2021: Mar. 17 Accounts receivable of $3,100 were written off as uncollectible. The company uses the allowance method. 30 Loaned an officer of the company $39,000 and received a note requiring principal and interest at 8% to be paid on March 30, 2022. May 30 Discounted the $39,000 note at...
Exercise 10-6 Sipacore produces a vitamin-enhanced dog food that is sold in Kansas. The company expects...
Exercise 10-6 Sipacore produces a vitamin-enhanced dog food that is sold in Kansas. The company expects sales to be 12,000 bags in January, 14,300 bags in February, 13,700 bags in March, and 16,200 bags in April. There are 1,390 bags on hand at the start of January. Sipacore desires to maintain monthly ending inventory equal to 15 percent of next month’s expected sales. Prepare the production budget for Sipacore for the months of January, February, and March. Sipacore Production Budget...
Short term (one year) interest years over the next 6 years will be0.9, 1.7, 1.1,...
Short term (one year) interest years over the next 6 years will be 0.9, 1.7, 1.1, 2.6, 3.2, and 3.9. Using the expectations theory, what will be the interest rates on 5-year bonds?
If $60,000 is paid at the end of each year for 13 years, calculate the equivalent...
If $60,000 is paid at the end of each year for 13 years, calculate the equivalent single payment now (P) if interest is 9% pa effective. Give your answer in dollars and cents to the nearest cent.
what is the solution to all parts Refer to the information in Exercise 6-7 and assume...
what is the solution to all parts Refer to the information in Exercise 6-7 and assume the periodic inventory system is used. Determine the costs assigned to ending inventory and to cost of goods sold using (a) FIFO and (b) LIFO. Then (c) compute the gross margin for each method date activities units acquired at cost units sold at retail jan 1 beginning inventory 200 units @ $10 = 2,000 jan 10 sales 150 units @ $40 Mar 14 purchase...
Exercise 6-21B Complete the accounting cycle using inventory transactions (LO6-2, 6-3, 6-5, 6-6, 6-7) [The following...
Exercise 6-21B Complete the accounting cycle using inventory transactions (LO6-2, 6-3, 6-5, 6-6, 6-7) [The following information applies to the questions displayed below.] On January 1, Year 1, the general ledger of a company includes the following account balances: Accounts Debit Credit Cash $ 22,500 Accounts Receivable 38,000 Allowance for Uncollectible Accounts $ 3,700 Inventory 33,000 Land 66,100 Accounts Payable 30,900 Notes Payable (8%, due in 3 years) 33,000 Common Stock 59,000 Retained Earnings 33,000 Totals $ 159,600 $ 159,600...
Exercise 6-21B Complete the accounting cycle using inventory transactions (LO6-2, 6-3, 6-5, 6-6, 6-7) [The following...
Exercise 6-21B Complete the accounting cycle using inventory transactions (LO6-2, 6-3, 6-5, 6-6, 6-7) [The following information applies to the questions displayed below.] On January 1, Year 1, the general ledger of a company includes the following account balances: Accounts Debit Credit Cash $ 22,500 Accounts Receivable 38,000 Allowance for Uncollectible Accounts $ 3,700 Inventory 33,000 Land 66,100 Accounts Payable 30,900 Notes Payable (8%, due in 3 years) 33,000 Common Stock 59,000 Retained Earnings 33,000 Totals $ 159,600 $ 159,600...
Exercise 6-21B Complete the accounting cycle using inventory transactions (LO6-2, 6-3, 6-5, 6-6, 6-7) [The following...
Exercise 6-21B Complete the accounting cycle using inventory transactions (LO6-2, 6-3, 6-5, 6-6, 6-7) [The following information applies to the questions displayed below.] On January 1, Year 1, the general ledger of a company includes the following account balances: Accounts Debit Credit Cash $ 22,500 Accounts Receivable 38,000 Allowance for Uncollectible Accounts $ 3,700 Inventory 33,000 Land 66,100 Accounts Payable 30,900 Notes Payable (8%, due in 3 years) 33,000 Common Stock 59,000 Retained Earnings 33,000 Totals $ 159,600 $ 159,600...
Exercise 6-21 Complete the accounting cycle using inventory transactions (LO6-2, 6-3, 6-5, 6-6, 6-7) Skip to...
Exercise 6-21 Complete the accounting cycle using inventory transactions (LO6-2, 6-3, 6-5, 6-6, 6-7) Skip to question [The following information applies to the questions displayed below.] On January 1, 2021, the general ledger of Big Blast Fireworks includes the following account balances: Accounts Debit Credit Cash $ 24,500 Accounts Receivable 43,000 Allowance for Uncollectible Accounts $ 2,900 Inventory 43,000 Land 81,100 Accounts Payable 28,700 Notes Payable (6%, due in 3 years) 43,000 Common Stock 69,000 Retained Earnings 48,000 Totals $...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT