+ 1

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; }

11th Apr 2021, 4:50 AM
Shravan Mathapati
Shravan Mathapati - avatar
6 Antworten
+ 4
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
11th Apr 2021, 4:58 AM
Simba
Simba - avatar
+ 4
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?
11th Apr 2021, 5:45 AM
Simba
Simba - avatar
+ 3
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"; }
11th Apr 2021, 5:45 AM
A͢J
A͢J - avatar
+ 1
11th Apr 2021, 6:08 AM
Shravan Mathapati
Shravan Mathapati - avatar
+ 1
#include <iostream> using namespace std; int main() { int hovercraft, sale; int costPerHovercraft = 2000000; // cost to manufacture one hovercraft int fixedCosts = 1000000; // fixed costs of the company cin>> hovercraft ; sale = hovercraft*3000000; //calculating total sales int totalCosts = hovercraft*costPerHovercraft + fixedCosts; //calculating total costs if(sale == totalCosts){ cout<<"Broke Even"; } else if (sale < totalCosts ){ cout<<"Loss"; } else { cout<<"Profit"; } return 0; }
21st Jan 2023, 1:30 PM
chudamani mandavi
chudamani mandavi - avatar
0
Simba can you explain, i couldn't understand what you told
11th Apr 2021, 5:03 AM
Shravan Mathapati
Shravan Mathapati - avatar