0
i dont understand why this doesn't work
#include <iostream> using namespace std; int main() { // your account's balance auto balance = 2452.4; // price for each notebook auto price = 259.99; auto notebooks = balance / price; auto rimasto = balance - (macbooks * price); cout << notebooks; cout << rimasto; // Task: calculate the number of notebooks you can afford and output it. // Hint: use an integer to store the result. // Task: calculate the amount left over on your account after the purchase and output it on a new line. // Hint: calculate the total price of the purchase, then substract it from the balance. }
5 Answers
+ 3
… have you changed the line suggested?
#include <iostream>
using namespace std;
int main() {
auto balance = 2452.4;
auto price = 259.99;
auto notebooks = balance / price;
auto rimasto = balance - (notebooks * price);
cout << notebooks;
cout << rimasto;
}
This is your code (comments removed). Where you had macbooks, changed to notebooks works fine for me. Outputs 9.432670
+ 2
thanks
+ 1
You haven’t declared or initialized the variable ‘macbooks’…
You cannot multiply an unknown 👍
0
it still doesn't work, i checked the comments and it seems that im not the only one with this problem
0
Try to end this code with return 0;