+ 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; }
6 ответов
+ 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
+ 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?
+ 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";
}
+ 1
🅰🅹 (Challenge Accepted) thank you 😅😅
+ 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;
}
0
Simba can you explain, i couldn't understand what you told