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

1st Feb 2023, 8:16 PM
comodinooarmadioo
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
1st Feb 2023, 8:30 PM
DavX
DavX - avatar
+ 2
thanks
1st Feb 2023, 8:32 PM
comodinooarmadioo
+ 1
You haven’t declared or initialized the variable ‘macbooks’… You cannot multiply an unknown 👍
1st Feb 2023, 8:20 PM
DavX
DavX - avatar
0
it still doesn't work, i checked the comments and it seems that im not the only one with this problem
1st Feb 2023, 8:26 PM
comodinooarmadioo
0
Try to end this code with return 0;
2nd Feb 2023, 2:07 AM
Memo
Memo - avatar