0

Code coach -Hovercraft

Dear all, My solution for the coding was the following(see below), but there must be a bug or so, because I don‘t get the button solved? Can You help me: what‘s wrong to get the mistake? Thanks to all! x = int(input()) if x >= 10: print("Profit") elif x < 6: print("Loss") else: print("Broke Even")

24th Jul 2022, 9:36 AM
Bianca Treis
7 Respostas
+ 3
Thanks a lot, I got it !! x = number_customers = int(input()) y = monthly_built_hovers = 10 i = insurance_monthly = 1000000 m = making_cost_month = 2000000 * y + i s = sold_cost = 3000000 * x z = profit_monthly = s - m # hover sold per 3000000, costs per hover 2000000, cost insurance monthly 1000000 if z > 0: print("Profit") elif z == 0: print("Broke Even") else: print("Loss")
24th Jul 2022, 11:13 AM
Bianca Treis
+ 2
Bianca Treis Might I suggest you use comments to describe aspects of your code instead of variable re-assignment. Example: x = int(input()) # number of sales y = 10 # hovers built per month etc....
24th Jul 2022, 11:38 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Description says : 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. " Read again. your x is hovercraft made. So find it's sold cost and making cost. Then find you got profit or loss or nothing ?
24th Jul 2022, 9:49 AM
Jayakrishna 🇼🇳
+ 1
Bianca Treis You haven't addressed the criteria of the challenge, you have just stuck some numbers in. Get the code to do the work for you by writing code which reflects the conditions of the challenge
24th Jul 2022, 9:51 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Bianca Treis Well done!
24th Jul 2022, 11:33 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
That’s code in java you can take idea about the solution import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int numOfhovercrafts=sc.nextInt(); //sells at month //int numOfhovercrafts=5; int insurance= 1000000; int costeverone=2000000; int selleverone=3000000; int spending=20000000; // static int sells=(numOfhovercrafts*selleverone)-insurance; if(sells>spending) { System.out.println("Profit"); } else if(spending>sells) { System.out.println("Loss"); } else if(sells==spending) { System.out.println("Broke Even"); } } }
24th Jul 2022, 3:27 PM
Mustafa Ali
Mustafa Ali - avatar
0
Ok.I’ ll try to improve.:)
24th Jul 2022, 11:41 AM
Bianca Treis