The python program allows the user to enter the Sales amount and Actual cost of a Product. Next, Python calculates the Loss Amount or profit Amount based on those two values using if-elif-else Statement

 Write Pseudocode and draw flow chart of the following problem .

The python program allows the user to enter the Sales amount and Actual cost of a Product. Next, Python calculates the Loss Amount or profit Amount based on those two values using if-elif-else Statement.

Answer-

Pseudocode

Input the Actual cost of  Product
Input the Sales Amount
if(actual_cost > sale_amount):
    amount = actual_cost - sale_amount
    print("Total Loss Amount")
elif(sale_amount > actual_cost):
    amount = sale_amount - actual_cost
    print("Total Profit ")
else:
    print("No Profit No Loss!!!")

Flow chart-

Python Code-

#Input Actual cost of  Product
actual_cost = float(input(" Please Enter the Actual cost of  Product:"))
# Input Sales Amount
sale_amount = float(input(" Please Enter the Sales Amount: "))
#calculate Loss Amount
if(actual_cost > sale_amount):
    amount = actual_cost - sale_amount
    print("Total Loss Amount = {0}".format(amount))
#Calculate Profit Amount 
elif(sale_amount > actual_cost):
    amount = sale_amount - actual_cost
    print("Total Profit = {0}".format(amount))
else:
    print("No Profit No Loss!!!") 

Output-
Please Enter the Actual cost of  Product:2500
 Please Enter the Sales Amount: 2600
Total Profit = 100.0


 Please Enter the Actual cost of  Product:2400
 Please Enter the Sales Amount: 2000
Total Loss Amount = 400.0





Comments

Popular posts from this blog

Mealy and Moore Machine

Context free grammar