+ 5
Hovercraft programme code coach
I have solved this.but 2/5 test cases faild.i can't identify what is the problem.please help me for identify problem. Is anyone solved this problem
16 Answers
+ 13
Pradeepa Samarathunga You have going on right approach you just missed or interpret one condition wrongly in else you should write "Loss" in the last statement
An another way you can try by reducing one variable
cost = 21000000
price =3000000
sales = int(input())
if sales*price>cost:
print('Profit')
elif sales*price==cost:
print('Broke Even')
else:
print('Loss')
+ 7
Pradeepa Samarathunga you still not changing the print statement it's "Loss" not "Lose"
+ 4
Pradeepa Samarathunga link your code which you have tried to getting solution.
+ 3
using System;
namespace HoverCraftFactory
{
class Program
{
public static void HoverCraftFactory()
{
int cost = 21000000;
int HoverCost = 3000000;
int sales = Convert.ToInt32(Console.ReadLine());
int income = sales * HoverCost;
if(income>cost)
{
Console.WriteLine("Profit");
}
else if (income ==cost)
{
Console.WriteLine("Broke Even");
}
else if (income<cost)
{
Console.WriteLine("Loss");
}
}
public static void Main(string[] args)
{
HoverCraftFactory();
}
}
}
//Here is an answer
+ 1
def converter(user):
monthly_loss = 21000000
insurance = 1000000
sale_value = 3000000
cost = (user * 3000000)
if cost > monthly_loss:
return "Profit"
elif cost < monthly_loss:
return "Loss"
elif cost == monthly_loss:
return "Broke Even"
user = int(input(""))
print(converter(user))
+ 1
Most simple solution.
sales = int(input())
if sales * 3 > 21:
print('Profit')
elif sales * 3 == 21:
print('Broke Even')
else:
print('Loss')
+ 1
//I'm using C language
#include<stdio.h>
int main()
{
int a,mult;
int b=3;
int c=21;
scanf("%d",&a);
mult=(a*b);
if (mult>c)
printf("profit");
else if(mult==c)
printf("Broke Even");
else
printf("Loss");
return 0;
}
0
https://www.sololearn.com/coach/42?ref=app
GAWEN STEASY
0
cost = 21000000
sales = int(input())
income = sales * 3000000
if income > cost :
print("Profit")
elif income < cost :
print("Lose")
elif income == cost:
print("Broke Even")
else:
print(None )
0
GAWEN STEASY
It looks like easy to work this code. Thank you very much ❤️
0
GAWEN STEASY
It has got same result ☹️
0
GAWEN STEASY
I got it.all test cases pass.i have written it as Lost and now corrected to Loss. Thank you so much ❤️
0
Why everyone is taking cost as 21,000,000?
0
#define MONEY_SPENT 21000000
#define PRICE_PER_UNIT sold*3000000
int main() {
int sold;
cin >> sold;
if(PRICE_PER_UNIT < MONEY_SPENT)
cout << "Loss" << endl;
else if(PRICE_PER_UNIT == MONEY_SPENT){
cout << "Broke Even" << endl;
}else
cout << "Profit";
}
0
sold = int(input())
total_cost = int(21000000)
income = int(sold*3000000)
if income>total_cost:
print("Profit")
elif income==total_cost:
print("Broke Even")
else:
print("Loss")
0
using System;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int sales = Convert.ToInt32(Console.ReadLine());
string result = DetermineProfitStatus(sales);
Console.WriteLine(result);
}
static string DetermineProfitStatus(int soldHovercrafts)
{
int hovercraftsBuilt = 10;
int costToBuild = 2000000;
int sellingPrice = 3000000;
int insuranceCost = 1000000;
int totalCost = hovercraftsBuilt * costToBuild + insuranceCost;
int totalRevenue = soldHovercrafts * sellingPrice;
if (totalRevenue > totalCost)
{
return "Profit";
}
else if (totalRevenue < totalCost)
{
return "Loss";
}
else
{
return "Broke Even";
}
}
}
}