Need help in hovercraft question | Sololearn: Learn to code for FREE!


Need help in hovercraft question

Here's my try๐Ÿ‘‡๐Ÿ‘‡ #include <iostream> using namespace std; int main() { int month, hovercraft; month = (10*2000000)+1000000; cin>> hovercraft ; int sale; sale = hovercraft*3000000; if(month=hovercraft){ cout<<"Broke Even"; } else if (month >hovercraft ){ cout<<"Loss"; } else { cout<<"Profit"; } return 0; }

4/11/2021 4:50:14 AM

Shravan Mathapati

5 Answers

New Answer


You need to use `==` operator to compare two variables. month == sale hovercraft is your input variable. You can use other variables to check the condition. month < sale


Nothing much! You can check why you declared month & sale variables once. Your month variable indicates how much money you spent to create hovercrafts whereas your sale variable indicates how much money you got by selling hovercrafts. Hovercraft is an input variable to count how many hovercrafts you sold. Let's say you sold 10 hovercrafts. So, hovercraft = 10 sale = 10*3000000 month = (10*200000)+1000000 Which two variables you will take to calculate the profit or loss?


Shravan Mathapati He want to say use double (==) for comparison because single equal (=) use for assignment hovercraft is a month so you can't compare with amount. You have to compare total amount with total sell So here month = (10 * 2000000) + 1000000; sale = hovercraft * 3000000; if (sale < month) { cout << "Loss"; } else if(sale > month) { cout << "Profit"; } else { cout << "Broken Even"; }


๐Ÿ…ฐ๐Ÿ…น (Challenge Accepted) thank you ๐Ÿ˜…๐Ÿ˜…


Simba can you explain, i couldn't understand what you told