Single File Programming QuestionProblem StatementAmit wants to evaluate the depreciation of his car over time to understand its current value and categorize it based on that value. Write a program that helps him determine the current value of his car after a certain number of years of depreciation and classify it into one of three categories:High: If the current value is greater than 10,000.Medium: If the current value is between 5,000 and 10,000, both inclusive.Low: If the current value is less than 5,000.The depreciation rate of the car is 15% per year. The program should calculate the current value of the car after applying this depreciation over the given number of years and print the current value along with the category.Company Tags: InfosysInput format :The first line of input consists of an integer, representing the initial cost of the car.The second line consists of an integer, representing the number of years the car has been depreciating.Output format :The first line of output prints a double value, representing the current value of the car, rounded off to two decimal places.The second line prints its category.Refer to the sample output for formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1 ≤ initial cost ≤ 1000000 ≤ age ≤ 100Sample test cases :Input 1 :200005Output 1 :Current Value: 8874.11Category: MediumInput 2 :155377Output 2 :Current Value: 4980.81Category: LowInput 3 :125751Output 3 :Current Value: 10688.75Category: HighNote :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Question
Single File Programming QuestionProblem StatementAmit wants to evaluate the depreciation of his car over time to understand its current value and categorize it based on that value. Write a program that helps him determine the current value of his car after a certain number of years of depreciation and classify it into one of three categories:High: If the current value is greater than 10,000.Medium: If the current value is between 5,000 and 10,000, both inclusive.Low: If the current value is less than 5,000.The depreciation rate of the car is 15% per year. The program should calculate the current value of the car after applying this depreciation over the given number of years and print the current value along with the category.Company Tags: InfosysInput format :The first line of input consists of an integer, representing the initial cost of the car.The second line consists of an integer, representing the number of years the car has been depreciating.Output format :The first line of output prints a double value, representing the current value of the car, rounded off to two decimal places.The second line prints its category.Refer to the sample output for formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1 ≤ initial cost ≤ 1000000 ≤ age ≤ 100Sample test cases :Input 1 :200005Output 1 :Current Value: 8874.11Category: MediumInput 2 :155377Output 2 :Current Value: 4980.81Category: LowInput 3 :125751Output 3 :Current Value: 10688.75Category: HighNote :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Solution
Here is a Python solution for the problem:
def calculate_depreciation(initial_cost, years):
current_value = initial_cost
for _ in range(years):
current_value *= 0.85
return current_value
def categorize_value(current_value):
if current_value > 10000:
return "High"
elif current_value >= 5000:
return "Medium"
else:
return "Low"
initial_cost = int(input())
years = int(input())
current_value = calculate_depreciation(initial_cost, years)
category = categorize_value(current_value)
print("Current Value: {:.2f}".format(current_value))
print("Category: {}".format(category))
This program works by first calculating the current value of the car after the given number of years of depreciation. It does this by multiplying the initial cost of the car by 0.85 (which represents a 15% decrease) for each year.
Then, it categorizes the current value into one of three categories: "High", "Medium", or "Low", based on the conditions given in the problem statement.
Finally, it prints the current value (rounded to two decimal places) and the category.
Similar Questions
Amit wants to evaluate the depreciation of his car over time to understand its current value and categorize it based on that value. Write a program that helps him determine the current value of his car after a certain number of years of depreciation and classify it into one of three categories:High: If the current value is greater than 10,000.Medium: If the current value is between 5,000 and 10,000, both inclusive.Low: If the current value is less than 5,000.The depreciation rate of the car is 15% per year. The program should calculate the current value of the car after applying this depreciation over the given number of years and print the current value along with the category.Company Tags: InfosysInput format :The first line of input consists of an integer, representing the initial cost of the car.The second line consists of an integer, representing the number of years the car has been depreciating.Output format :The first line of output prints a double value, representing the current value of the car, rounded off to two decimal places.The second line prints its category.
Single File Programming QuestionProblem StatementMeet Alex, a budget-savvy shopper who wants to give discounts to customers in the following ways:If the amount is greater than 5000 (not inclusive), the discount is 20%.If it is greater than 2000 (not inclusive), the discount is 15%.10% discount for a purchase amount greater than 1000 (not inclusive). Write a program that takes the amount as input and calculates the discounts using a function named applyDiscount. The discount rates are set as 10%, 15%, and 20% as global double datatype variables.Input format :The input consists of a double value representing the amount.Output format :The output displays "Discounted amount: " followed by a double value representing the discounted amount, rounded to two decimal places.Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1000.0 ≤ Amount ≤ 10000.0Sample test cases :Input 1 :2000.0Output 1 :Discounted amount: 1800.00Input 2 :1100.50Output 2 :Discounted amount: 990.45Input 3 :10000.0Output 3 :Discounted amount: 8000.00Input 4 :1000.0Output 4 :Discounted amount: 1000.00
Single File Programming QuestionProblem StatementAthul, a supermarket employee, needs a program to calculate Goods and Services Tax (GST) deductions for customer purchases. The program should take a purchase code (A to F) and amount, apply the relevant GST rate, subtract it from the original amount, and print the result. The user's total amount and product code are used to calculate the GST.For example, if the amount is 100.00 and the product code is 'C', 5% GST is applied, and the amount is calculated as 100.00 - (100.00*0.05) which is equal to 95.00.Input format :The first line of the input consists of a character representing the product code ('A', 'B', 'C', 'D', 'E', or 'F').The second line consists of a float value representing the total amount.Output format :If the code is valid ('A', 'B', 'C', 'D', 'E', or 'F'), the output displays a float value representing the amount after deducting GST, rounded off to two decimal places, after applying the appropriate GST deduction.If the code is invalid, it displays "Invalid choice".Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:100.0 ≤ total amount ≤ 10000.0Sample test cases :Input 1 :C100.00Output 1 :95.00Input 2 :A2000.00Output 2 :2000.00Input 3 :W2300.67Output 3 :Invalid choiceInput 4 :B10000.00Output 4 :9800.00Input 5 :D1234.52Output 5 :1086.38Input 6 :E5678.00Output 6 :4655.96Input 7 :F9789.00Output 7 :7048.08Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Single File Programming QuestionProblem StatementLilly went shopping with a budget of Rs. 10,000 to buy clothes, and accessories. The cost of clothes is twice the value of accessories, and there is an additional expense of Rs. 1000 for fuel. Develop an expense calculator by inputting the amount spent on accessories, then calculate and display Lilly's remaining amount rounded to two decimal places after her shopping.ExampleInput:2000.0Output:3000.0Explanation:budget = 10000.0;fuel = 1000.0;accessories = 2000.0clothes = 2 * accessories = 2 * 2000 = 4000.0total = clothes + accessories + fuel = 4000.0 + 2000.0 + 1000.0 = 7000.0remaining = budget - total = 10000.0 - 7000.0 = 3000.0Input format :The input consists of a float value a, representing the amount spent on accessories.Output format :The output prints the remaining budget after shopping, rounded to two decimal places in the following format: "Rs. [remaining amount]". Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:10.0 ≤ a ≤ 3000.0Sample test cases :Input 1 :10.0Output 1 :Rs. 8970.00Input 2 :2000.0Output 2 :Rs. 3000.00Input 3 :3000.0Output 3 :Rs. 0.00Input 4 :1578.89Output 4 :Rs. 4263.33
Single File Programming QuestionProblem StatementJames is a meticulous traveler who is calculating the total cost of his road trip. James considers factors such as distance traveled, gas consumption, average miles per liter, parking fees, and toll charges. The program takes inputs for miles traveled, gas consumed, average miles per liter, parking fees, and toll charges, and computes the total cost using the formula:The result is then displayed with four two-decimal places. The program utilizes arithmetic operators for the calculations.Input format :The first line consists of the total number of miles traveled per day as an integer.The second line consists of the cost of gas per liter as an integer.The third line consists of the average miles per liter of gas as a positive double-point number.The fourth line consists of the parking cost as an integer.The last line consists of the toll cost as an integer.Output format :The output displays a double value representing the total cost calculated based on the given formula with rounded-off to decimal places.Refer to the sample output for the formatting specifications.Code constraints :In the given scenario, the test cases fall under the following constraints:1 ≤ miles ≤ 10050 ≤ cost of gas ≤ 1505.0 ≤ average_miles ≤ 60.010 ≤ parking charge ≤ 10050 ≤ toll cost ≤ 500Sample test cases :Input 1 :1505.01050Output 1 :70.00Input 2 :587010.54565Output 2 :496.67Input 3 :10015060.0100500Output 3 :850.00Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.