+ 2
Need help on hovercraft test c++
For some reason every time i try and run the code i get no output why? https://sololearn.com/coach/42/?ref=app
4 Answers
+ 8
balance needs to be equal to loss for Broke Even to print.
Also, output variables should be same as given in task. "Profit", "Loss"...
+ 2
Show your try so that we can help.
+ 2
#include <iostream>
using namespace std;
int main() {
int hovercraftSold, balance;
int cost = 20000000;
//cost to make 10 hovercrafts
int rent = 1000000;
//cost of rent a month
int loss = cost + rent;
//total loss for a month
cin >> hovercraftSold;
//takes input of how many hovercrafts sold
balance = hovercraftSold * 3000000;
//calculates profit made
if(balance > loss){
cout << "proft" << endl;
}
if(balance < loss){
cout << "loss" << endl;
}
if(balance == 0){
cout << "Broke even" << endl;
}
return 0;
}
0
#include <iostream>
using namespace std;
int main() {
int hovercraftSold, balance;
int cost = 20000000;
//cost to make 10 hovercrafts
int rent = 1000000;
//cost of rent a month
int loss = cost + rent;
//total loss for a month
cin >> hovercraftSold;
//takes input of how many hovercrafts sold
balance = hovercraftSold * 3000000;
//calculates profit made
if(balance > loss){
cout << "Profit" << endl;
}
if(balance < loss){
cout << "Loss" << endl;
}
if(balance == loss){
cout << "Broke Even" << endl;
}
return 0;
}