Help solve the problem | Sololearn: Learn to code for FREE!

+2

Help solve the problem

How to solve the problem? Here is the task: You run a hovercraft factory. Your factory makes ten hovercrafts in a month. Given the number of customers you got that month, did you make a profit? It costs you 2,000,000 to build a hovercraft, and you are selling them for 3,000,000. You also pay 1,000,000 each month for insurance. Task: Determine whether or not you made a profit based on how many of the ten hovercrafts you were able to sell that month. Input Format: An integer that represents the sales that you made that month. Output Format: A string that says 'Profit', 'Loss', or 'Broke Even'. Sample Input: 5 Sample Output: Loss Entering 10 displays an error. Please indicate the error in the code. sales = int(input()) balance = int(sales*1000000-1000000) if balance > 0: print('Profit') elif balance == 0: print('Broke Even') else: print('Loss')

2/14/2020 1:49:16 PM

Vlad

8 Answers

New Answer

+1

Sorry if I wrong said about problem

+1

Vlad The code is wrong. If I sold 2 hovercrafts in the month: Earn: 6M: Selling 2 hovercrafts (2*3M=6M) Loss: 28M: Creating 10 hovercrafts (10*2M=20M) Insurance of 8 hovercrafts (8*M=8M) 6M - 28M = -22M (loss) In your code it would be: sales = 2 balance = sales * M - M = 2M - M = +M (profit)

+1

Ah, I thought insurance didn’t apply to ships. Thanks you

+1

Hare is solution of your problem order= int(input()) sales=order*3000000 cost=20000000 balance = int(sales-21000000) if balance > 0: print('Profit') elif balance == 0: print('Broke Even') else: print('Loss')

+1

I did mine using C++ but its not working #include <iostream> using namespace std; int main() { int sales; double S_P=3000000, Insurance=1000000,C_P=2000000,Amount_received; const int Num=10; double principal_amount=(C_P*Num)+Insurance; cout<<"Enter the number of customers: "; cin>>sales; Amount_received=(sales*S_P); if(Amount_received<principal_amount) { cout<<"Loss"; } if(Amount_received>principal_amount) { cout<<"Profit"; } if(Amount_received==principal_amount) { cout<<"Broken Even"; } return 0; }

+1

yo Vlad this is the code I wrote with explanations you can run it and see, it works but just go through why it works, dont want to just solve it for you without helping #just assigning a variable to 21 million, this is the amount spent on making 10 hovercrafts in a month #this is usefull in later calculations per_month_payments = 21000000 #getting input of how many hovercrafts were sold hovercrafts_sold_month = int(input("How many hovercrafts were sold? ")) print(hovercrafts_sold_month) #getting the amount of money I- the company made cash_made_from_HCs = hovercrafts_sold_month * 3000000 #cashiness is used in calculating if I- we the company made a profit a loss or if it was Broke e- Even cashiness = cash_made_from_HCs - per_month_payments if hovercrafts_sold_month <= 10: if cashiness > 0: print("Profit") elif cashiness == 0: print("Broke Even") elif cashiness < 0: print("Loss") else: print("how would I- The company sell more hovercrafts then I made??? Sorry didn't mean I made, I meant WE made")

0

Seems to be a logic error.

0

i translated incorrectly. In test with in input 7 programm output profit. But this is a wrong answer. Is it a mistake in the task or mine in code? Code work good.