+ 3
Code coach
Did my first code coach am I missing something it had multiple answers so I did one function got one answer right green tick but other answers were marked wrong. Ok so maybe it wants all inputs from 0 - 10 for the hoverboard code coach so I did inputs as a list a for loop nope didn’t accept that so thought I’ll do a while loop plus 1 to the input just in case it took the list as one input and no. Then it dawned on me maybe the person who wrote the exercise didn’t put a or condition on the win conditions.
12 Respuestas
+ 5
It sounds like you're hard-coding.
If I set a task and I want to add 2 numbers and as a test case I write the answer as 4, most people would hard code something like:
print(2+2)
That gives 4, sure, test case answered. However, what the question is actually asking is for 2 numbers of any input.
So, it'd be better:
a = user input
b = user input
print(a+b)
See if that helps your thinking/code coach solving.
If you want someone to look at your code specifically, you can attach it as per this:
https://code.sololearn.com/Wek0V1MyIR2r/?ref=app
https://code.sololearn.com/W3uiji9X28C1/?ref=app
+ 2
Please share your code
+ 1
All good thanks ausgrindtube had the same issue and yeah as soon as i used userinput she worked like a dream.
+ 1
Happy it worked out for you matey.
Enjoy your coding journey!
+ 1
Pls am new to coding here🙏
+ 1
Isaac Aromokun firstly, welcome then!
Can you please read the following and see if you can learn something new so you solve your problem yourself.
If you still can't, no problem, start a new thread with your problem (information on that below too).
https://www.sololearn.com/discuss/3021159/?ref=app
https://code.sololearn.com/W0uW3Wks8UBk/?ref=app
https://code.sololearn.com/Wek0V1MyIR2r/?ref=app
https://code.sololearn.com/W3uiji9X28C1/?ref=app
0
/*""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.
0
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: */
let hoverCraft = 2000000
let salePrice = 3000000
let insurance = 1000000
let inventory = 10
0
let costs = (inventory * hoverCraft) + insurance
//let inputSales = readLine() tried this
//let sales = Int(inputSales)
let sales = 7
func bank() {
if (sales * salePrice) > costs
{
print("Profit")
}
else if (sales * salePrice) < costs
{
print("Loss")
}
else
{
print("Broke Even")
}
}
bank()
0
/* tried this for every option
let sales = [0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10]
for sale in sales {
if (sale * salePrice) > costs{
print("Profit")
}
else if (sale * salePrice) < costs{
print("Loss")
}
else {
print("Break Even")
}
}
\*
0
func bank {
while (sales < 10) {
if (sales * salePrice) > costs
{
print ("Profit" )
}
else if (sales * salePrice) < costs
{
print ("Loss'")
}
else
{
print ("Broke Even")
}
sales += 1
}
}
bank()
0
Ran that as well all the code works just the multiple conditions arent satisfied like they forgot to put if answer is this or this or this mark as pass and it wont except multiple answers like the while or for loops