+ 4

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')

14th Feb 2020, 1:49 PM
Vlad
13 Answers
+ 2
Ah, I thought insurance didn’t apply to ships. Thanks you
14th Feb 2020, 5:36 PM
Vlad
+ 1
Sorry if I wrong said about problem
14th Feb 2020, 1:54 PM
Vlad
+ 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)
14th Feb 2020, 5:34 PM
Seb TheS
Seb TheS - avatar
+ 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')
12th May 2020, 6:18 AM
Kartik Singh
Kartik Singh - avatar
+ 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")
30th Oct 2020, 4:52 PM
Doggo
Doggo - avatar
+ 1
#FROM PYTHON sale=int(input()) Cp=2*10+1 Sp=3*sale if Cp>Sp: print("Loss") if Cp<Sp: print("Profit") if Cp==Sp: print("Broke Even")
14th Jan 2022, 8:01 AM
The Dr.
+ 1
#python kater = int(input()) #кількість проданих катерів min = 21000000 """min - це загальна кількість вират: на виготовлення (10*2млн) і страховку (1млн)""" katers = kater*3000000 """прибуток з продажу""" profit = katers - min #обчислення загального прибутку if profit == 0: print ("Broke Even") #якщо витрати=прибутку elif profit > 0: print ("Profit") #якщо прибуток>витрат else: print ("Loss") #якщо прибуток<вират
10th Mar 2022, 4:47 PM
Богдан Гнатюк
Богдан Гнатюк - avatar
+ 1
n = int(input()) if n > 7: print("Profit") elif n < 7 : print("Loss") else : print("Broke Even")
31st Jul 2022, 5:11 PM
Максут Кудайбергенов
Максут Кудайбергенов - avatar
0
Seems to be a logic error.
14th Feb 2020, 4:40 PM
Seb TheS
Seb TheS - avatar
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.
14th Feb 2020, 5:16 PM
Vlad
0
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; }
28th Sep 2020, 6:16 AM
S.T.I.G.A.R
S.T.I.G.A.R - avatar
0
Я не знаю как у меня это сработало, но это работает :/ C++ #include <iostream> using namespace std; int main() { int N = 0; cin >> N; if (N < 7){ cout << "Loss"; } else if (N >= 8){ cout << "Profit"; } else if (N <= 7){ cout << "Broke Even"; } return 0; }
4th Jun 2022, 9:42 AM
ლĐīmåლ
ლĐīmåლ - avatar
0
Very Simple Way To Solve! import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int sales = sc.nextInt(); if (sales<5 && sales>=0) { System.out.println("Loss"); }else if (sales==7){ System.out.println("Broke Even"); }else if (sales>7 && sales<=10){ System.out.println("Profit"); } } }
30th Aug 2022, 6:12 AM
ROSHAN ABICHANDANI
ROSHAN ABICHANDANI - avatar